/** * {@inheritDoc} */ public function get_excluded_options($key, $action, $current_value, &$field_data, $step) { if ($step == 2 && $key == 'field_maxlen') { // Get the number of options if this key is 'field_maxlen' return sizeof(explode("\n", $this->request->variable('lang_options', '', true))); } return parent::get_excluded_options($key, $action, $current_value, $field_data, $step); }
/** * {@inheritDoc} */ public function get_excluded_options($key, $action, $current_value, &$field_data, $step) { if ($step == 2 && $key == 'field_default_value') { // Permit an empty string if ($action == 'create' && $this->request->variable('field_default_value', '') === '') { return ''; } } return parent::get_excluded_options($key, $action, $current_value, $field_data, $step); }
/** * {@inheritDoc} */ public function prepare_hidden_fields($step, $key, $action, &$field_data) { if ($key == 'field_default_value') { $always_now = $this->request->variable('always_now', 0); if ($always_now) { return 'now'; } else { if ($this->request->is_set('field_default_value_day')) { $field_data['field_default_value_day'] = $this->request->variable('field_default_value_day', 0); $field_data['field_default_value_month'] = $this->request->variable('field_default_value_month', 0); $field_data['field_default_value_year'] = $this->request->variable('field_default_value_year', 0); return sprintf('%2d-%2d-%4d', $field_data['field_default_value_day'], $field_data['field_default_value_month'], $field_data['field_default_value_year']); } } } return parent::prepare_hidden_fields($step, $key, $action, $field_data); }
/** * {@inheritDoc} */ public function prepare_hidden_fields($step, $key, $action, &$field_data) { if ($key == 'field_default_value') { $field_length = $this->request->variable('field_length', 0); // Do a simple is set check if using checkbox. if ($field_length == 2) { return $this->request->is_set($key); } return $this->request->variable($key, $field_data[$key], true); } $default_lang_options = array('l_lang_options' => array(0 => array('')), 'lang_options' => array(0 => '')); if (isset($default_lang_options[$key]) && $this->request->is_set($key)) { return $this->request->variable($key, $default_lang_options[$key], true); } return parent::prepare_hidden_fields($step, $key, $action, $field_data); }
/** * {@inheritDoc} */ public function get_excluded_options($key, $action, $current_value, &$field_data, $step) { if ($step == 2 && $key == 'field_default_value') { // 'field_length' == 1 defines radio buttons. Possible values are 1 or 2 only. // 'field_length' == 2 defines checkbox. Possible values are 0 or 1 only. // If we switch the type on step 2, we have to adjust field value. // 1 is a common value for the checkbox and radio buttons. // Adjust unchecked checkbox value. // If we return or save settings from 2nd/3rd page // and the checkbox is unchecked, set the value to 0. if ($this->request->is_set('step') && !$this->request->is_set($key)) { return 0; } // If we switch to the checkbox type but former radio buttons value was 2, // which is not the case for the checkbox, set it to 0 (unchecked). if ($field_data['field_length'] == 2 && $current_value == 2) { return 0; } // If we switch to the radio buttons but the former checkbox value was 0, // which is not the case for the radio buttons, set it to 0. else if ($field_data['field_length'] == 1 && $current_value == 0) { return 2; } } if ($key == 'l_lang_options' && $this->request->is_set($key)) { $field_data[$key] = $this->request->variable($key, array(0 => array('')), true); return $current_value; } return parent::get_excluded_options($key, $action, $current_value, $field_data, $step); }