form_set_value

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/form.inc, строка 1313

Версии
5
form_set_value($form, $value)
6
form_set_value($form_item, $value, &$form_state)

Изменяет отправленные значения формы во время цикла обработки формы.

Используйте эту функцию для изменения отправленного значения элемента формы во время фазы валидации, чтобы оно сохранилось в $form_state до фазы обработки и попало в обработчики.

Since $form_state['values'] can either be a flat array of values, or a tree of nested values, some care must be taken when using this function. Specifically, $form_item['#parents'] is an array that describes the branch of the tree whose value should be updated. For example, if we wanted to update $form_state['values']['one']['two'] to 'new value', we'd pass in $form_item['#parents'] = array('one', 'two') and $value = 'new value'.

Параметры

$form_item The form item that should have its value updated. Keys used: #parents, #value. In most cases you can just pass in the right element from the $form array.

$value The new value for the form item.

$form_state The array where the value change should be recorded.

Связанные темы

▾ 8 функции вызывают form_set_value()

node_search_validate in modules/node/node.module
Form API callback for the search form. Registered in node_form_alter().
node_teaser_include_verify in modules/node/node.module
Ensure value of 'teaser_include' checkbox is consistent with other form data.
node_teaser_js in modules/node/node.module
See if the user used JS to submit a teaser.
password_confirm_validate in includes/form.inc
Validate password_confirm element.
search_form_validate in modules/search/search.pages.inc
As the search form collates keys from other modules hooked in via hook_form_alter, the validation takes place in _submit. search_form_validate() is used solely to set the 'processed_keys' form value for the basic search form.
user_pass_validate in modules/user/user.pages.inc
_form_builder_handle_input_element in includes/form.inc
Populate the #value and #name properties of input elements so they can be processed and rendered. Also, execute any #process handlers attached to a specific element.
_install_settings_form_validate in ./install.php
Helper function for install_settings_validate.

Код

<?php
function form_set_value($form_item, $value, &$form_state) {
  _form_set_value($form_state['values'], $form_item, $form_item['#parents'], $value);
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему