Top Left Text cha

Web & App Development

Should mention this method is for Chronforms 5.  It is not quite the same for previous versions.

Under Setup Section

  • Drag a 'DB Read' action onto the on load area - before the 'HTML (render form)' action.  You can leave the 'on found' and 'on not found' areas empty, but I put an 'event loop' into the 'on not found' area.  If there's any chance that the field will be blank, do not put a 'event loop' action in there.  I suggest not doing that in general after all the troubleshooting I did before realizing that the field could be blank - in which case send the form into a loop.
  • Click 'edit' on that action.
  • Select the table you want to retrieve data from.  I'll use 'users' as an example.
  • Multi-read will usually be yes unless you want less than one field returned.
  • Enable model ID MUST be yes.  The directions I read before said it was optional, but that's not true.  
  • Create a unique model id and enter it into that field.  I'll use 'names' for the model ID as an example.
  • Enter the field or fields.  I'll use 2 for an example (id,name).
  • You can ignore the rest of the fields, but you may want to use the conditional.  Here's an example from my form where I only wanted to show registered users ('registered' id in the system is 2)... 
    <?php
    return array('user_group' => '2');
    ?>

Under Designer Section

  • Drag a new form field onto the form.  I'm using a dropdown for my example.
  • In the 'general' tab, name your form.  I used the same name as the model (names).  This might be required (to be identical to the model).
  • I removed the default 'yes=1, no=2' that is in the 'options' box.

Dynamic Data Tab

  • Under the 'dynamic data' tab, set 'enabled' to 'yes'.
  • Data path will be the model ID.  This is what was missing on the instructions from the developers.  So I set it to 'names'.
  • The 'value key' and 'text key' are basically the options like you would set on the previous tab if you weren't using dynamic data to populate your field.  So, I used 'id' for the value key and 'name' for the text key.  This will show the user the names and save it under the IDs.  You could also use 'name' for both and it would show the user the names and also save the name they select.




Add comment


Security code
Refresh

  • Guest - joe

    nothing to do, it does not work and the information is too coarse.
    no tutorial on this, at least for the V5!
    it seems really impossible.
    chronoengine in the forum, which seem to love riddles.....

    from Italy
  • I know... it's very complex.

    One thing I did to make sure everything was 'in sync' was named everything the same. For example, I would name the country field 'nameCountry', the id 'nameCountry', and the model ID 'nameCountry'. That's one little thing that I figured out. I don't know if they all need to be the same, but I think it doesn't work if some of them aren't the same. I'll paste the code I have in my DB Read actions. Of course, they'll be different, but maybe the example will help...

    DB Read Configuration:
    Enabled: yes
    Table Name: 2sc_comprofiler
    Multi Read: yes
    Enable Model ID: yes
    Model ID: profile
    Fields: id,cb_com_company
    Conditions:

    <?php return array('cb_accounttype' => 'Company'); ?>


    Then, under the dropdown field for this DB Read action - in the 'Dynamic Data' tab:
    Enabled: yes
    Data Path: profile
    Value Key: cb_com_company
    Text Key: cb_com_company

    In the general tab for this dropdown, my field name and id are both: profile


    2nd DB Read & Dropdown

    DB Read Configuration:
    Enabled: yes
    Table Name: 2sc_cert8130
    Multi Read: yes
    Enable Model ID: yes
    Model ID: formfile
    Fields: user_id,created,tracking,name13,name14,cf_pdf_file,company,attach
    Conditions:
    <?php
    $user = JFactory::getUser(); 
    return array('user_id' => $user->id);
    ?>


    Then, under the dropdown field for this DB Read action - in the 'Dynamic Data' tab:
    Enabled: yes
    Data Path: formfile
    Value Key: cf_pdf_file
    Text Key: tracking

    In the general tab for this dropdown, my field name and id are both: formfile

  • In the condidtions of the second DB Read Action, you're going to need something like 'where country=$country'. Which might be something like...

    <?php
    $country = $form->data['nameCountry'];
    return array('country' => $country);
    ?>


    Most likely won't work out of the box like that, but maybe something similar. Maybe not. Every case is different for this stuff.

  • Hi Joe,

    I've successfully built one before. I now need a second one and have been working for the past 5 hours trying to get it to work. I'm going to start back over on it from scratch. If I don't have any luck, I'll probably go to the Chronoforms forum and post. I'll let you know where the post is or if I've found a solid solution.

  • Guest - joe

    How do I build a Double Drop-down in CFv5
    I found no tutorial that worked with ChronoForms V5, you can write one?
    thank you
    in my database 2 tables
    country and region
    fields country; id nameCountry
    fields region; id nameRegion idCountry

    from Italy
  • Hey Joe.... I got it working again. I don't know why it wasn't working. I basically started over, followed my directions on this page, and it worked. Basically, you just need 2 DB Read actions first thing in the 'on load' of the setup tab. And 2 dropdowns. Then I just duplicated my instructions on this page over for each DB Read/Dropdown.

    Of course, the first thing you're going to have to do is build the database tables with the countries & regions. Your situation might be a little more complex since it needs to compare one table to the other in order to know what regions to display. I swear I saw an article on exactly what you're doing. Let me look real quick...

    I didn't find exactly what I was looking for, but I found someone with a similar issue - and there's multiple links on the thread pointing to possible solutions (I didn't check them out), but maybe this will help.

Leave your comments

Post comment as a guest

0
Your comments are subjected to administrator's moderation.
X