Results 1 to 9 of 9

Thread: Custom checkbox field in basic search form

  1. #1
    ramendrasinghrathore@hotmail.com Guest

    Default Custom checkbox field in basic search form

    Hi

    I want to add a checkbox field in basic search of lead module which works like checkbox "My items".

    1. I add a non db definition

    $dictionary['Lead']['fields']['current_status']= array('name' => 'current_status',
    'label' => 'Current',
    'type' => 'bool',
    'source' => 'non-db','default' => '0');

    This creates a checkbox field,I add this field in basic search using admin studio and add query definition in searchfields.php .

    Everything works fine except one thing I want a checkbox in basic search but there is a dropdown (select box showing with yes,no option).

    I want checkbox there what wrong I did in code I don't understand

    Hope any one has solution for this problem

    Thanks in advance.

  2. #2
    ramendrasinghrathore@hotmail.com Guest

    Default Re: Custom checkbox field in basic search form

    any suggestion

  3. #3
    davidboris's Avatar
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,525

    Default Re: Custom checkbox field in basic search form

    Hi,

    Their is nothing wrong in that, SugarCRM It self convert checkbox to dropdown in searchview.
    Yes, It can be solved by overriding field type in custom.
    Web : http://www.urdhva-tech.com
    Twitter : @urdhvatech
    Email : contact@urdhva-tech.com
    Blog : Urdhva-Tech
    Skype : urdhvatech

    Our Premium Projects for SugarCRM:
    Premium theme for SugarCRM CE (Community Edition 6.5+ with 4 combinations, Black + Orange/Red/Green/Blue, bootstrap3 based)
    Duplicate detector to avoid duplicate data entry.
    Customer Self Service Portal for All Flavours.
    tagMe A complete tag management for SugarCRM.
    Meeting Map Reminder Meeting reminder with Gmap in Email

  4. #4
    ramendrasinghrathore@hotmail.com Guest

    Default Re: Custom checkbox field in basic search form

    Thanks for reply I already did code in custom.

    I have created a test checkbox field from admin it's working fine in all form but in search form it's displaying a select box instead of checkbox.

    Is any thing tricky about that..??

  5. #5
    davidboris's Avatar
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,525

    Default Re: Custom checkbox field in basic search form

    Hello,

    I meant override field type as in include/SugarFields/Fields/Bool to custom/include/SugarFields/Fields/Bool
    Web : http://www.urdhva-tech.com
    Twitter : @urdhvatech
    Email : contact@urdhva-tech.com
    Blog : Urdhva-Tech
    Skype : urdhvatech

    Our Premium Projects for SugarCRM:
    Premium theme for SugarCRM CE (Community Edition 6.5+ with 4 combinations, Black + Orange/Red/Green/Blue, bootstrap3 based)
    Duplicate detector to avoid duplicate data entry.
    Customer Self Service Portal for All Flavours.
    tagMe A complete tag management for SugarCRM.
    Meeting Map Reminder Meeting reminder with Gmap in Email

  6. #6
    ramendrasinghrathore@hotmail.com Guest

    Default Re: Custom checkbox field in basic search form

    Great thanks.

    I am going to try that.

  7. #7
    ramendrasinghrathore@hotmail.com Guest

    Default Re: Custom checkbox field in basic search form

    Hello

    Thanks for help the problem is solved.

    As by default the field type for search template was select box at location: include\SugarFields\Fields\Bool\SearchView.tpl

    As you suggest to override I override this selectbox with checkbox in search tpl.

    I want to share the code that I changed.

    custom\include\SugarFields\Fields\Bool\SearchView. tpl

    {if strval({{sugarvar key='value' stringFormat='false'}}) == "1" || strval({{sugarvar key='value' stringFormat='false'}}) == "yes" || strval({{sugarvar key='value' stringFormat='false'}}) == "on"}
    {assign var="checked" value="CHECKED"}
    {else}
    {assign var="checked" value=""}
    {/if}


    <input type="checkbox" id="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}"
    name="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}"
    value="1" title='{{$vardef.help}}' tabindex="{{$tabindex}}" {{if !empty($displayParams.accesskey)}} accesskey='{{$displayParams.accesskey}}' {{/if}}
    {$checked} {{$displayParams.field}}>

  8. #8
    davidboris's Avatar
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,525

    Default Re: Custom checkbox field in basic search form

    Hi,

    Ok, great.
    Web : http://www.urdhva-tech.com
    Twitter : @urdhvatech
    Email : contact@urdhva-tech.com
    Blog : Urdhva-Tech
    Skype : urdhvatech

    Our Premium Projects for SugarCRM:
    Premium theme for SugarCRM CE (Community Edition 6.5+ with 4 combinations, Black + Orange/Red/Green/Blue, bootstrap3 based)
    Duplicate detector to avoid duplicate data entry.
    Customer Self Service Portal for All Flavours.
    tagMe A complete tag management for SugarCRM.
    Meeting Map Reminder Meeting reminder with Gmap in Email

  9. #9
    ramendrasinghrathore@hotmail.com Guest

    Default Re: Custom checkbox field in basic search form

    The best way is to override SugarFieldBool.php

    function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) {
    $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex);
    //If there was a type override to specifically render it as a boolean, show the EditView checkbox
    if( preg_match("/(favorites|current_user|open)_only.*/", $vardef['name']))
    {
    return $this->fetch($this->findTemplate('EditView'));
    } else {
    return $this->fetch($this->findTemplate('SearchView'));
    }
    }


    The bold condition where we can change according our requirement..

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. Replies: 3
    Last Post: 2010-05-11, 10:30 AM
  2. How to create a Checkbox in Basic Search Area?
    By kamalesh2008 in forum Developer Help
    Replies: 2
    Last Post: 2010-04-06, 06:14 AM
  3. Create checkbox like 'Only my items' in search form
    By s0me1 in forum Developer Help
    Replies: 0
    Last Post: 2009-12-10, 05:17 AM
  4. Replies: 2
    Last Post: 2009-05-22, 12:04 PM
  5. Hot to define a checkbox in custom field search
    By dsharma in forum General Discussion
    Replies: 0
    Last Post: 2006-07-19, 03:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •