AS and default values

liquidcms - March 16, 2007 - 18:22
Project:Active Select
Version:4.7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Maybe i am just doing something wrong here but am i correct in assuming that you can't set default values with AS?

I think the values get loaded with the page - and then the AS does it's thing and writes over them. So, i see the correct values there briefly, and the first category keeps it's default; but then it loads the options for the 2nd (which then loads the 3rd) and no longer as the defaults. Hmmm.. perhaps i am just doing something wrong here.. will take another look before attempting a (JS ??) fix for this.

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

#1

radiantflow - March 20, 2007 - 13:25

I also get this problem.

I open an edit form (i'm using this with the location module), the target is correctly set as selected, but then on the page load the target list is updated and activeselect loses which one is selected.

Ben

#2

liquidcms - March 21, 2007 - 22:42

ok, well good to know i am not just using it wrong.

I have AS as part of a multipage form (as well as a few other places). And the point of the mpage is to be able to go back/forward through the pages and keep values.

Bottom line is i will need to get this to work on this project so hopefully will get it fixed in the next week or so. In my case at least it looks like it should be fixable ... the default values are there to start with.. so "simply" a case of making sure it doesnt do the update if there are already values...

#3

liquidcms - April 6, 2007 - 20:26

i think that the best answer to this is that it should not do anything on first load of the page.. not sure there is much of a dwonside to this ???

the only thing that i think the first load does is to remove all the items that are in the secondary selects (which really shouldnt be there anyway)

#4

Robert S - June 16, 2007 - 08:21

Did you find any solution to this issue?
Can you give the rest of us a hint? - I suppose there is quite a few people who ran into this, too.
Thanks a lot.

#5

liquidcms - June 19, 2007 - 14:15

not sure i could be of much help.. i have gotten this to work.. but it is pretty messy. I use AS in 3 places in my latest project and for each of them i end up simply copying the AS code from the module and modifying it.

hints i can give you :

- do a search on "DANGEROUS_SKIP_CHECK" as there is a post here which sort of explains some of this
- also #activeselect_extra is used

my code wouldn't make any sense since it is quite different than the original.

looking back on the project; i am sure it would have been faster to design my own AJAX select function than try to use this one.

sorry and good luck

#6

vanvemden - July 5, 2007 - 15:04

I ran into the same problem when using AS for my custom CCK field (in Drupal 5) and found the solution in the category.module (line 1182)

              '#activeselect_extra' => ($node->nid ? $node->nid : 0). ($default_cat ? ','. $default_cat : ''),

where it set the current value of the target field ($default_cat) in the form.
In the category_activeselect function the value is obtained from $extra (line 1370)
  $parent_cont = $extra_array[1];

and the default value is set in $options array (line 1407)
        $options[$key]['selected'] = in_array($key, $parents);

Hope this helps.

 
 

Drupal is a registered trademark of Dries Buytaert.