By chaosprinz on
Hello,
like the title tells ya, i'm using hook_form_alter() to change the Options of a CCK-Textfield using a radio-buttons widget, which should be used on both: the node-add- and the node-edit-form.
But its shown on the node-add-form only. On node-edit it doesnt take effect. Best will be, i show ya the code:
function clavisto_evt_register_form_alter(&$form, &$form_state, $form_id){
if($form_id == 'events_node_form'){
$options = array();
$types = node_get_types('types');
foreach($types as $key => $type){
if(preg_match("/^events_reg/",$type->type)) {
$options[] = $type->name;
}
$options_str = implode("\n",$options);
$form['#field_info']['field_evt_regform']['allowed_values'] = $options_str;
dsm($form['#field_info']);
}
}
Its strange, because when i look into the information of the dsm-command for '#field_info', the right infos are stored in the 'allowed' values, but the html shows the infos as they are stored at the db.
Has anyone an idea where i have to search for my failure?
Sorry, if my english isnt so good, i hope you understand everything. Thx for ya thoughts.
Comments
Why are you using
Why are you using
$form['#field_info']and not the actual form element to change the options?There is no special reason,
There is no special reason, but it was the only array i found, which is holding the options-data.
A look at $form['field_evt_regform'] shows me something like this:
I know, in a default-fapi-widget i would use #options to hold the options-data. In case of a cck-field with optionswidgets_button-widget, there isnt something like #options. I tried this already.
Do you think i have change the whole field, starting from type?
You might need to make your
You might need to make your changes with after_build. see http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
I tried it with
I tried it with '#after_build' and '#pre_render' now, where i called a function that does something like this:
In both, '#after_build' and '#pre_render' it does render the title and an empty div.form-radios, but no input-element.