/** * Method to attach a JForm object to the field. * * @param object $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @since 11.1 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); $defaultToTableValue = $this->element->attributes()->default_to_table; if ($defaultToTableValue) { $defaultToTableValue = (bool) $this->element->attributes()->{$defaultToTableValue}[0]; } else { $defaultToTableValue = true; } if ($this->value == '' && $return && $defaultToTableValue) { $db = JFactory::getDbo(); /* * Attempt to get the real Db collation (tmp fix before this makes it into J itself * see - https://github.com/joomla/joomla-cms/pull/2092 */ $db->setQuery('SHOW VARIABLES LIKE "collation_database"'); try { $res = $db->loadObject(); if (isset($res->Value)) { $this->value = $res->Value; } } catch (RuntimeException $e) { $this->value = $db->getCollation(); } } return $return; }
/** * Test the getInput method. */ public function testGetInput() { $form = new JFormInspector('form1'); $this->assertThat( $form->load('<form><field name="list" type="list" /></form>'), $this->isTrue(), 'Line:'.__LINE__.' XML string should load successfully.' ); $field = new JFormFieldList($form); $this->assertThat( $field->setup($form->getXml()->field, 'value'), $this->isTrue(), 'Line:'.__LINE__.' The setup method should return true.' ); $this->assertThat( strlen($field->input), $this->greaterThan(0), 'Line:'.__LINE__.' The getInput method should return something without error.' ); // TODO: Should check all the attributes have come in properly. }
public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); // On change must always be the change context function $this->onchange = 'dpFieldsChangeContext(jQuery(this).val());'; return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->folder = (string) $this->element['folder']; } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->allowAdd = isset($this->element['allowAdd']) ? $this->element['allowAdd'] : ''; } return $return; }
public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->filter = (string) $this->element['filter']; $this->exclude = (string) $this->element['exclude']; $hideNone = (string) $this->element['hide_none']; $this->hideNone = $hideNone == 'true' || $hideNone == 'hideNone' || $hideNone == '1'; // Get the path in which to search for file options. $this->directory = (string) $this->element['directory']; } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->keyField = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value'; $this->valueField = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name']; $this->translate = $this->element['translate'] ? (string) $this->element['translate'] : false; $this->query = (string) $this->element['query']; } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->filter = (string) $this->element['filter']; $this->exclude = (string) $this->element['exclude']; $this->stripPrefix = (string) $this->element['stripprefix']; $this->defaultLabel = (string) $this->element['defaultlabel']; $hideNone = (string) $this->element['hide_none']; $this->hideNone = $hideNone == 'true' || $hideNone == 'hideNone' || $hideNone == '1'; $hideDefault = (string) $this->element['hide_default']; $this->hideDefault = $hideDefault == 'true' || $hideDefault == 'hideDefault' || $hideDefault == '1'; $stripExt = (string) $this->element['stripext']; $this->stripExt = $stripExt == 'true' || $stripExt == 'stripExt' || $stripExt == '1'; // Get the path in which to search for file options. $this->directory = (string) $this->element['directory']; } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $this->checkedOptions = (string) $this->element['checked']; } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 3.2 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { // Check if its using the old way $this->query = (string) $this->element['query']; if (empty($this->query)) { // Get the query from the form $query = array(); $defaults = array(); $query['select'] = (string) $this->element['sql_select']; $query['from'] = (string) $this->element['sql_from']; $query['join'] = isset($this->element['sql_join']) ? (string) $this->element['sql_join'] : ''; $query['where'] = isset($this->element['sql_where']) ? (string) $this->element['sql_where'] : ''; $query['group'] = isset($this->element['sql_group']) ? (string) $this->element['sql_group'] : ''; $query['order'] = (string) $this->element['sql_order']; // Get the filters $filters = isset($this->element['sql_filter']) ? explode(",", $this->element['sql_filter']) : ''; // Get the default value for query if empty if (is_array($filters)) { foreach ($filters as $key => $val) { $name = "sql_default_{$val}"; $attrib = (string) $this->element[$name]; if (!empty($attrib)) { $defaults[$val] = $attrib; } } } // Process the query $this->query = $this->processQuery($query, $filters, $defaults); } $this->keyField = isset($this->element['key_field']) ? (string) $this->element['key_field'] : 'value'; $this->valueField = isset($this->element['value_field']) ? (string) $this->element['value_field'] : (string) $this->element['name']; $this->translate = isset($this->element['translate']) ? (string) $this->element['translate'] : false; $this->header = $this->element['header'] ? (string) $this->element['header'] : false; } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. * * @see JFormField::setup() * @since 1.2.0 */ public function setup(SimpleXMLElement $element, $value, $group = null) { $return = parent::setup($element, $value, $group); if ($return) { $attributes = array('exclude', 'class'); /* class is @deprecated >= J3.2 */ foreach ($attributes as $attributeName) { if (isset($element[$attributeName])) { $this->__set($attributeName, $element[$attributeName]); } } } return $return; }
/** * Method to attach a JForm object to the field. * * @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. * @param mixed $value The form field value to validate. * @param string $group The field name group control value. This acts as as an array container for the field. * For example if the field has name="foo" and the group value is set to "bar" then the * full field name would end up being "bar[foo]". * * @return boolean True on success. */ public function setup(SimpleXMLElement $element, $value, $group = null) { $input = \Windwalker\DI\Container::getInstance()->get('input'); $this->container = \Windwalker\DI\Container::getInstance($input->get('option')); return parent::setup($element, $value, $group); }