Hello everybody:
In our new site we need camputed date, so we investigate in the forums to do this, but we haven't the solution. So for resolve this me edit the select.inc component for put the options on the fly.
The part we modified is in the _webform_select_options function
We insert this piece of code in the function
if(stripos($text, '<?php') !== FALSE){
$text = str_ireplace('<?php','',$text);
$text = str_ireplace('?>','',$text);
eval($text);
$text = $opcions;
}
The only limitations is that you must write the options in the $opcions variable as we can see in the example
<?php
$opcions="option1|option2\n";
?>;
The other thing we changed is for have the default value of textfiled computed. We edit textfield.inc and we insert this code
if(stripos($component['value'], '<?php') !== FALSE){
$text = str_ireplace('<?php','',$component['value']);
$text = str_ireplace('?>','',$text);
eval($text);
$component['value'] = $default_value;
}
in the _webform_render_textfield function. As the other inc that we modified the limitation is that we must declare the variable with the $default_value name as we can see in this code
<?php $default_value="dummy";?>
If you need you could modify the other components ot the webform in the same direction.
We attach the two components with the changes we comment here....
Sorry for my english....
Xarbot
| Comment | File | Size | Author |
|---|---|---|---|
| webform_components.zip | 6.75 KB | xarbot |
Comments
Comment #1
quicksketch#151603: Can I put options in a select field from a database query? or
#406486: Allow pluggable select list values