/** * @param array $input_args { * @type string $html_name the html name for the input * @type string $html_label_id the id attribute to give to the html label tag * @type string $html_label_class the class attribute to give to the html label tag * @type string $html_label_style the style attribute to give ot teh label tag * @type string $html_label_text the text to put in the label tag * @type string $html_label the full html label. If used, all other html_label_* args are invalid * @type string $html_help_text text to put in help element * @type string $html_help_style style attribute to give to teh help element * @type string $html_help_class class attribute to give to the help element * @type string $default default value NORMALIZED (eg, if providing the default for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0') * @type EE_Display_Strategy_Base $display strategy * @type EE_Normalization_Strategy_Base $normalization_strategy * @type EE_Validation_Strategy_Base[] $validation_strategies * } */ public function __construct($input_args = array()) { // the following properties must be cast as arrays $set_as_array = array('validation_strategies'); // loop thru incoming options foreach ($input_args as $key => $value) { // add underscore to $key to match property names $_key = '_' . $key; if (property_exists($this, $_key)) { // first check if this property needs to be set as an array if (isset($set_as_array[$key])) { // ensure value is an array $value = is_array($value) ? $value : array($value); // and merge with existing values $this->{$_key} = array_merge($this->{$_key}, $value); } else { $this->{$_key} = $value; } } } // ensure that "required" is set correctly $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); $this->_html_name_specified = isset($input_args['html_name']) ? TRUE : FALSE; $this->_display_strategy->_construct_finalize($this); if ($this->_validation_strategies) { foreach ($this->_validation_strategies as $validation_strategy) { $validation_strategy->_construct_finalize($this); } } if (!$this->_normalization_strategy) { $this->_normalization_strategy = new EE_Text_Normalization(); } $this->_normalization_strategy->_construct_finalize($this); //at least we can use the normalization strategy to populate the default if (isset($input_args['default'])) { $this->set_default($input_args['default']); } if (!$this->_sensitive_data_removal_strategy) { $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); } $this->_sensitive_data_removal_strategy->_construct_finalize($this); parent::__construct($input_args); }
/** * @param array $input_args { * @type string $html_name the html name for the input * @type string $html_label_id the id attribute to give to the html label tag * @type string $html_label_class the class attribute to give to the html label tag * @type string $html_label_style the style attribute to give ot teh label tag * @type string $html_label_text the text to put in the label tag * @type string $html_label the full html label. If used, * all other html_label_* args are invalid * @type string $html_help_text text to put in help element * @type string $html_help_style style attribute to give to teh help element * @type string $html_help_class class attribute to give to the help element * @type string $default default value NORMALIZED (eg, if providing the default for a Yes_No_Input, * you should provide TRUE or FALSE, not '1' or '0') * @type EE_Display_Strategy_Base $display strategy * @type EE_Normalization_Strategy_Base $normalization_strategy * @type EE_Validation_Strategy_Base[] $validation_strategies * } */ public function __construct($input_args = array()) { $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); // the following properties must be cast as arrays if (isset($input_args['validation_strategies'])) { foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { if ($validation_strategy instanceof EE_Validation_Strategy_Base) { $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; } } unset($input_args['validation_strategies']); } // loop thru incoming options foreach ($input_args as $key => $value) { // add underscore to $key to match property names $_key = '_' . $key; if (property_exists($this, $_key)) { $this->{$_key} = $value; } } // ensure that "required" is set correctly $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : null); //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; $this->_display_strategy->_construct_finalize($this); foreach ($this->_validation_strategies as $validation_strategy) { $validation_strategy->_construct_finalize($this); } if (!$this->_normalization_strategy) { $this->_normalization_strategy = new EE_Text_Normalization(); } $this->_normalization_strategy->_construct_finalize($this); //at least we can use the normalization strategy to populate the default if (isset($input_args['default'])) { $this->set_default($input_args['default']); } if (!$this->_sensitive_data_removal_strategy) { $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); } $this->_sensitive_data_removal_strategy->_construct_finalize($this); parent::__construct($input_args); }