Results 1 to 9 of 9

Thread: Checkbox in search on-off or 1 and 0 (Community Module Builder)

  1. #1
    groberts100 is offline Member
    Join Date
    Sep 2007
    Posts
    7

    Default Checkbox in search on-off or 1 and 0

    Hi,

    I am pulling my hair out and there is not much to spare. I have added a checkbox to the advanced search by editing the module's search form.

    The search fails because the generated where clause is

    where (assessments.assm_cancelled like 'on%')

    and the value stored in the database is either 0 or 1.

    I have looked all over the place for somewhere to configure how bool fields are persisted, but had no luck.

    Any suggestions welcome,

    Thanks,

    Guy Roberts

  2. #2
    groberts100 is offline Member
    Join Date
    Sep 2007
    Posts
    7

    Default Re: Checkbox in search on-off or 1 and 0

    I should have said that the field is being saved and recovered correctly, its just the search where clause that is wrong.

    Also, I've knocked up a dummy module with Module Builder and included a bool field in the search and that seems to work.

    I can't use Module Builder for the module in question because we've had to split the Edit and Detail views into four different pairs of files to display four sub classes of the module in edit and detail mode.

  3. #3
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Checkbox in search on-off or 1 and 0

    Hi groberts100, I moved this thread down to the Release 5.0 Community Preview discussion area.

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

  4. #4
    franklin_sugar is offline Sugar Team Member
    Join Date
    Jun 2006
    Posts
    157

    Default Re: Checkbox in search on-off or 1 and 0

    Hi groberts100,

    I created a checkbox in Accounts module's advanced search and couldn't see the problem you described. What is your environment? Like operating system, web server, database, and PHP version. Can you describe your steps to produce this problem? I assume you used 5.0 beta2 release.

    Thanks,
    Franklin

  5. #5
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Checkbox in search on-off or 1 and 0

    Hey Franklin, I think Jason just encountered a related issue. See bug 12624.

    It's all about mapping the 'on' value to 1, and the 'off' value to 0. Or, in actuality, that this is not occurring.

    In Jason's case this was occurring during a POST but the same issue most likely explains the issue groberts100 is describing here.

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

  6. #6
    groberts100 is offline Member
    Join Date
    Sep 2007
    Posts
    7

    Default Re: Checkbox in search on-off or 1 and 0

    Franklin,

    Icould not see the bug page that was mentioned but here's how I can reproduce my problem;

    I use a clean version of SugarOS-Full-4.5.1e (Mac OS 10.4, MAMP (PHP 5 ,Apache, MySQL 5.0) and install a beta version of Module Builder (BuilderWizard-V5.0.0.b.beta.zip).

    Then I create a module called Holidays with two fields, a text field called destination and a checkbox called "Have you remembered the children".

    Once installed, if I check "Have you remembered the children" in the basic search panel no records are returned, even though they exist.

    If I put a log message in the module's List.php file right after $where is set,

    $GLOBALS['log']->info("Here is the where clause for the list view: $where");

    I see this is in the log file

    Here is the where clause for the list view: holidays.kmps_have_you_remembered_the_children like 'on%'

    Which won't work because the mysql table column is a tinyint(1), not a Varchar.

    I know I should not be using the Beta version of Module builder but we are half way through a project that started before Sugar 5.0 came out, so cannot upgrade at this time.

    Thanks for any ideas,

    Guy

  7. #7
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Checkbox in search on-off or 1 and 0

    Hi groberts100, it turns out that the issue you ran into is a different, but related, bug that apparently surfaces when using the version of the Module Builder available from the Sugar community and not the Module Builder that is included in core Sugar product beginning with Release 5.0.

    I apolgizoe for the confusion.

    Your best bet now is to work with the creator off the community's Module Builder (use the link above to contact the developer). I will also move this thread to the appropriate spot in the forums so it can gain the attention of the community in this regard.

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

  8. #8
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Checkbox in search on-off or 1 and 0

    I've moved this thread to the Downloads section and renamed the subject to clearly call out that the issue arises when using the community's Module Builder.

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

  9. #9
    groberts100 is offline Member
    Join Date
    Sep 2007
    Posts
    7

    Default Re: Checkbox in search on-off or 1 and 0 (Community Module Builder)

    Thank you both for diagnosing the problem, it has helped me decide what to do.

    In case anybody else ever googles this here is my workaround;

    Because this is a rare issue caused by a Beta version of module builder, I decided to work around it by changing the where clause string in the ListView.php file of my newly generated module as follows.

    $where = str_replace('like \'on%\'', " = 1", $where);
    $where = str_replace('like \'off%\'', " = 0", $where);

    Its a bodge but after initial testing I think it does the trick.

    Laziness is a virtue and wading into a forest of PHP is a bad thing.

Thread Information

Users Browsing this Thread

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

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
  •