Results 1 to 7 of 7

Thread: form question

  1. #1
    User
    Join Date
    07-06-09.
    Posts
    44

    Default form question

    Hi,
    I'd like to know how to insert a conditional situation in a form and save it into a DB.

    I'd like to select a Region from a Country.
    Then depending on the Region to select the Province.
    Then depending on the Province to select the City.

    Schematically it should be:

    Select Region ---------> Select Province-------------->Select City.

    Any idea?

    Thanx,
    Dan

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: form question

    You can use the conditional select menu, though that will be a lot of work that you may need to automate in some way. I tested it to work for three levels.

    So level 1 will be a regular menu, and the two levels below will both be conditional selects.

    These are my fields, if you change the ids and pids you should be able to insert on 2.11. Take care to also change the field the conditional selects refer to if you change the id's. best to do that using contao...
    Code:
    INSERT INTO `tl_form_field` (`id`, `pid`, `sorting`, `tstamp`, `invisible`, `type`, `name`, `label`, `text`, `html`, `options`, `mandatory`, `rgxp`, `maxlength`, `size`, `fSize`, `multiple`, `mSize`, `extensions`, `storeFile`, `uploadFolder`, `useHomeDir`, `doNotOverwrite`, `fsType`, `value`, `placeholder`, `class`, `accesskey`, `tabindex`, `addSubmit`, `slabel`, `imageSubmit`, `singleSRC`, `conditionField`) VALUES
    (1, 1, 128, 1340289177, '', 'select', 'subject', '', NULL, NULL, 'a:3:{i:0;a:2:{s:5:"value";s:1:"1";s:5:"label";s:1:"1";}i:1;a:2:{s:5:"value";s:1:"2";s:5:"label";s:1:"2";}i:2;a:2:{s:5:"value";s:1:"3";s:5:"label";s:1:"3";}}', '', '', 0, 'a:2:{i:0;i:4;i:1;i:40;}', 0, '', 0, 'jpg,jpeg,gif,png,pdf,doc,xls,ppt', '', '', '', '', 'fsStart', '', '', '', '', 0, '', '', '', '', 0),
    (2, 1, 256, 1340289171, '', 'conditionalselect', 'e-mail', '', NULL, NULL, 'a:13:{i:0;a:3:{s:5:"value";s:1:"1";s:5:"label";s:1:"1";s:5:"group";s:1:"1";}i:1;a:2:{s:5:"value";s:3:"1.1";s:5:"label";s:3:"1.1";}i:2;a:2:{s:5:"value";s:3:"1.2";s:5:"label";s:3:"1.2";}i:3;a:3:{s:5:"value";s:1:"2";s:5:"label";s:1:"2";s:5:"group";s:1:"1";}i:4;a:2:{s:5:"value";s:3:"2.1";s:5:"label";s:3:"2.1";}i:5;a:2:{s:5:"value";s:3:"2.2";s:5:"label";s:3:"2.2";}i:6;a:2:{s:5:"value";s:3:"2.3";s:5:"label";s:3:"2.3";}i:7;a:2:{s:5:"value";s:3:"2.4";s:5:"label";s:3:"2.4";}i:8;a:3:{s:5:"value";s:1:"3";s:5:"label";s:1:"3";s:5:"group";s:1:"1";}i:9;a:2:{s:5:"value";s:3:"3.a";s:5:"label";s:3:"3.a";}i:10;a:2:{s:5:"value";s:3:"3.b";s:5:"label";s:3:"3.b";}i:11;a:2:{s:5:"value";s:3:"3.c";s:5:"label";s:3:"3.c";}i:12;a:2:{s:5:"value";s:3:"3.d";s:5:"label";s:3:"3.d";}}', '', '', 0, 'a:2:{i:0;i:4;i:1;i:40;}', 0, '', 0, 'jpg,jpeg,gif,png,pdf,doc,xls,ppt', '', '', '', '', 'fsStart', '', '', '', '', 0, '', '', '', '', 1),
    (3, 1, 384, 1340289336, '', 'conditionalselect', 'message', '', NULL, NULL, 'a:24:{i:0;a:3:{s:5:"value";s:1:"1";s:5:"label";s:1:"1";s:5:"group";s:1:"1";}i:1;a:3:{s:5:"value";s:3:"1.1";s:5:"label";s:3:"1.1";s:5:"group";s:1:"1";}i:2;a:2:{s:5:"value";s:5:"1.1.a";s:5:"label";s:5:"1.1.a";}i:3;a:3:{s:5:"value";s:3:"1.2";s:5:"label";s:3:"1.2";s:5:"group";s:1:"1";}i:4;a:2:{s:5:"value";s:5:"1.2.a";s:5:"label";s:5:"1.2.a";}i:5;a:3:{s:5:"value";s:1:"2";s:5:"label";s:1:"2";s:5:"group";s:1:"1";}i:6;a:3:{s:5:"value";s:3:"2.1";s:5:"label";s:3:"2.1";s:5:"group";s:1:"1";}i:7;a:2:{s:5:"value";s:5:"2.1.a";s:5:"label";s:5:"2.1.a";}i:8;a:3:{s:5:"value";s:3:"2.2";s:5:"label";s:3:"2.2";s:5:"group";s:1:"1";}i:9;a:2:{s:5:"value";s:5:"2.2.a";s:5:"label";s:5:"2.2.a";}i:10;a:3:{s:5:"value";s:3:"2.3";s:5:"label";s:3:"2.3";s:5:"group";s:1:"1";}i:11;a:2:{s:5:"value";s:5:"2.3.a";s:5:"label";s:5:"2.3.a";}i:12;a:3:{s:5:"value";s:3:"2.4";s:5:"label";s:3:"2.4";s:5:"group";s:1:"1";}i:13;a:2:{s:5:"value";s:5:"2.4.a";s:5:"label";s:5:"2.4.a";}i:14;a:3:{s:5:"value";s:1:"3";s:5:"label";s:1:"3";s:5:"group";s:1:"1";}i:15;a:3:{s:5:"value";s:3:"3.a";s:5:"label";s:3:"3.a";s:5:"group";s:1:"1";}i:16;a:2:{s:5:"value";s:5:"3.a.1";s:5:"label";s:5:"3.a.1";}i:17;a:2:{s:5:"value";s:5:"3.a.2";s:5:"label";s:5:"3.a.2";}i:18;a:3:{s:5:"value";s:3:"3.b";s:5:"label";s:3:"3.b";s:5:"group";s:1:"1";}i:19;a:2:{s:5:"value";s:4:"3.b1";s:5:"label";s:4:"3.b1";}i:20;a:3:{s:5:"value";s:3:"3.c";s:5:"label";s:3:"3.c";s:5:"group";s:1:"1";}i:21;a:2:{s:5:"value";s:4:"3.c2";s:5:"label";s:4:"3.c2";}i:22;a:3:{s:5:"value";s:3:"3.d";s:5:"label";s:3:"3.d";s:5:"group";s:1:"1";}i:23;a:2:{s:5:"value";s:5:"3.d22";s:5:"label";s:5:"3.d22";}}', '', '', 0, 'a:2:{i:0;i:4;i:1;i:40;}', 0, '', 0, 'jpg,jpeg,gif,png,pdf,doc,xls,ppt', '', '', '', '', 'fsStart', '', '', '', '', 0, '', '', '', '', 2);

  3. #3
    User
    Join Date
    07-06-09.
    Posts
    44

    Default Re: form question

    Hi Ruud, thank you for your reply and for the SQL statement.
    I hoped there was a more "natural" way through EFG but it seems not. I'll try to work it out as pointed by you and I have to pay great attention since I have to deal with around 10 000 items....
    Thank you,
    Dan

  4. #4
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: form question

    I'm not sure about efg, don't use it often. It may have expanded this behavior. Perhaps you are better of with a custom widget modeled of a conditional select. The conditional gets values from a single blob. I'm guessing all values are in the html (need to check). With 10000 items you do not want that for sure.

  5. #5
    User
    Join Date
    07-06-09.
    Posts
    44

    Default Re: form question

    Guess this problem does not have a straightforward solution. I know it sounds blasphemic but drupal has an easy to do conditional select solution, but I don't want to change CMS

  6. #6
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: form question

    In Drupal just about everything is coming from the taxonomy. There is a taxonomy extension for Contao. But that won't be a solution on it's own, that would be a means to add all the data that you need. From there you need a conditional select widget that uses the taxonomy.

    Could you figure out the drupal solution mechanism? If it uses the taxonomy, how data is inserted into the taxonomy, but more importantly how it updates the select fields. Does it use ajax?

  7. #7
    User
    Join Date
    07-06-09.
    Posts
    44

    Default Re: form question

    Well, perhaps I'll be working on an extension that does what I am trying to accomplish.
    Quote Originally Posted by Ruud
    Could you figure out the drupal solution mechanism? If it uses the taxonomy, how data is inserted into the taxonomy, but more importantly how it updates the select fields. Does it use ajax?
    I don't know....

    Dankjewel

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
  •