/** * adds a field to the current form * * @param mixed $field field to add as an array or a FormField object */ public function addField($field) { //adds the field directly to the form fields if $field is a FormField object if (isFormFieldKwixo($field)) { $this->fields[] = $field; } //creates an object KwixoFormField and adds it to the fields list if $field is an array if (is_array($field)) { $new_field = new KwixoFormField(); //if $field contains a label key if (array_key_exists('label', $field)) { //sets the new field label $new_field->setLabel($field['label']); //destroy the label idex not to read it again later unset($field['label']); } //sets field params foreach ($field as $name => $value) { $funcname = 'set' . $name; $new_field->{$funcname}($value); } $this->fields[] = $new_field; } }
public function __construct($src, $name = 'submit', $label = null, $alt = null, $class = 'inputimageclass', $id = null) { parent::__construct('image', $name, null, $id, $class, $label); $this->setSrc($src); $this->setAlt($alt); }