Revision cd5c298a
Added by Geoffroy Desvernay over 5 years ago
drupal7/includes/form.inc | ||
---|---|---|
555 | 555 |
* Stores a form in the cache. |
556 | 556 |
*/ |
557 | 557 |
function form_set_cache($form_build_id, $form, $form_state) { |
558 |
// 6 hours cache life time for forms should be plenty. |
|
559 |
$expire = 21600; |
|
558 |
// The default cache_form expiration is 6 hours. On busy sites, the cache_form |
|
559 |
// table can become very large. A shorter cache lifetime can help to keep the |
|
560 |
// table's size under control. |
|
561 |
$expire = variable_get('form_cache_expiration', 21600); |
|
560 | 562 |
|
561 | 563 |
// Ensure that the form build_id embedded in the form structure is the same as |
562 | 564 |
// the one passed in as a parameter. This is an additional safety measure to |
... | ... | |
1438 | 1440 |
// length if it's a string, and the item count if it's an array. |
1439 | 1441 |
// An unchecked checkbox has a #value of integer 0, different than string |
1440 | 1442 |
// '0', which could be a valid value. |
1441 |
$is_empty_multiple = (!count($elements['#value'])); |
|
1443 |
$is_countable = is_array($elements['#value']) || $elements['#value'] instanceof Countable; |
|
1444 |
$is_empty_multiple = $is_countable && count($elements['#value']) == 0; |
|
1442 | 1445 |
$is_empty_string = (is_string($elements['#value']) && drupal_strlen(trim($elements['#value'])) == 0); |
1443 | 1446 |
$is_empty_value = ($elements['#value'] === 0); |
1444 |
if ($is_empty_multiple || $is_empty_string || $is_empty_value) { |
|
1447 |
$is_empty_null = is_null($elements['#value']); |
|
1448 |
if ($is_empty_multiple || $is_empty_string || $is_empty_value || $is_empty_null) { |
|
1445 | 1449 |
// Although discouraged, a #title is not mandatory for form elements. In |
1446 | 1450 |
// case there is no #title, we cannot set a form error message. |
1447 | 1451 |
// Instead of setting no #title, form constructors are encouraged to set |
Also available in: Unified diff
MAJ 7.60 -> 7.62