/** * Overload: set property * * @param string $name * @param mixed $value * @return void */ public function __set($name, $value) { if (!in_array($name, $this->_allowed)) { throw new FFR_Model_Exception(sprintf('Invalid parameter "%s" specified', $name)); } $inputFilter = $this->getForm('CreateFormField'); $element = $inputFilter->getElement($name); if ($element) { if ($name == 'form_field_id') { $element->removeValidator('DB_NoRecordExists'); } if (!$element->isValid($value)) { throw new FFR_Model_Exception(sprintf('Invalid value specified for %s: %s', $name, $value)); } $value = $element->getValue(); } if ($name == 'form_field_attribs' || $name == 'form_field_options') { if (is_string($value)) { $this->_data[$name] = unserialize($value); } else { $this->_data[$name] = $value; } } else { $this->_data[$name] = $value; } if ($name == 'form_field_attribs') { // Store the field name $filter = new Zend_Filter_Word_SeparatorToSeparator(' ', '_'); $name = $filter->filter(strtolower(preg_replace('/[^A-Za-z0-9 ]/', '', $this->_data[$name]['Label']))); $this->_data['form_field_name'] = $name; } }
public function testFilterSeparatesWordsWithSearchAndReplacementSpecified() { $string = 'dash=separated=words'; $filter = new Zend_Filter_Word_SeparatorToSeparator('=', '?'); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('dash?separated?words', $filtered); }
/** * Returns the resource ID for the model in the form model:name * * @return string */ public function getResourceId() { $filter = new Zend_Filter_Word_SeparatorToSeparator('_', '.'); $className = strtolower($this->getClassType($this)); $resourceId = 'model:' . $filter->filter(str_replace('model_', '', $className)); return $resourceId; }