Esempio n. 1
0
 /**
  * Constructor for a form.
  *
  * Creates a named form with the given parameters.
  * Also sets the id of the form to "form-$name" (simplifying the contents of the $name in the process).
  * If this isn't what you want just overwrite the id by setting your own straight after the form is constructed and before you
  * call add() to put elements into your form.
  * This id of the form will be used as a prefix to the id of everything you then add to the form so there should be no collisions
  * between form-generated ids and ids you use elsewhere in your pages.
  **/
 public function __construct($name, $action, $method = "post")
 {
     fxAssert::isNonEmptyString($name, 'name', "Form must be named.");
     parent::__construct($name);
     $method_wl = array('post', 'get');
     $method = strtolower($method);
     fxAssert::isInArray($method, $method_wl);
     $this->_method = $method;
     $this->_action = $action;
     $this->id = self::_simplify("form-{$name}");
     $this->errors = array();
 }
 public function renderSelect(fxFormElementSet &$e, fxForm &$f, $parent_id)
 {
     $o = array();
     $attr = $this->renderAtts($e->_getInfoExcept('class,value,id'));
     $id = $this->makeId($e, $parent_id);
     $label = htmlspecialchars($e->_name);
     $multi = $e->_inData('multiple');
     $class = $this->getClasses($e, $multi ? 'mselect' : 'select');
     $o[] = "<select {$id}{$attr}{$class}>";
     $o[] = $this->renderOptions($e->_members, $e, $f);
     $o[] = '</select>';
     $errmsg = $this->addErrorMessage($e, $f);
     if ('' !== $errmsg) {
         $o[] = $errmsg;
     }
     $o = implode("\n", $o);
     $o = $this->addLabel($o, $e, $parent_id);
     $this->checkExposure($e, $o);
     return $o;
 }
Esempio n. 3
0
 public function __construct($name, $label, $members)
 {
     fxAssert::isArray($members, 'members') && fxAssert::isNotEmpty($members, 'members');
     parent::__construct($name, $label);
     $this->_members = $members;
     $this->id = $tmp = fxForm::_simplify($name);
     $this->name = $tmp . '[]';
     $this->_mmap = self::makeMemberMap($members);
 }