public function importXml(SimpleXMLElement $xml) { parent::importXml($xml); foreach ($this->_xml->option as $option) { $elem = KFactory::tmp('admin::com.ninja.form.element.select.radio')->importXml($option); $this->addOption($elem); } if ($this->_xml['get']) { $get = isset($this->_xml['tmp']) && $this->_xml['tmp'] == true ? KFactory::tmp(new KIdentifier($this->_xml['get'])) : KFactory::get(new KIdentifier($this->_xml['get'])); if ($this->_xml['set']) { $json = '{"' . str_replace(array(';', ':'), array('","', '":"'), (string) $this->_xml['set']) . '"}'; $states = json_decode(str_replace('",""}', '"}', $json)); foreach ($states as $state => $set) { $get->{$state}($set); } } $key = $this->_xml['key'] ? $this->_xml['key'] : 'title'; $val = $this->_xml['val'] ? $this->_xml['val'] : 'id'; foreach ($get->getList() as $item) { $string = '<option value="' . $item->{$val} . '">' . $item->{$key} . '</option>'; $elem = KFactory::tmp('admin::com.ninja.form.element.select.radio')->importXml(simplexml_load_string($string)); $this->addOption($elem); } } return $this; }
/** * Import an XML element definition * * @param SimpleXMLElement SimpleXMLElement object * @return NinjaFormElementSelectOption */ public function importXml(SimpleXMLElement $xml) { parent::importXml($xml); $this->setValue((string) $this->_xml['value']); $this->setLabel((string) $this->_xml['label']); return $this; }
public function importXml(SimpleXMLElement $xml) { parent::importXml($xml); foreach ($this->_xml->option as $option) { $elem = KFactory::tmp('admin::com.ninja.form.element.select.checkbox')->importXml($option); $this->addOption($elem); } return $this; }