Add select element


@param $name
@param $label
@param array $multi
@param array $attr
@return \FrenchFrogs\Form\Element\Select
358607
public function addSelect($name, $label, $multi = [],  $is_mandatory = true)
    {
        $e = new \FrenchFrogs\Form\Element\Select($name, $label, $multi);
        $this->addElement($e);

        if ($is_mandatory) {
            $e->addRule('required');
        } else {
            $e->addFilter('nullable');
        }

        return $e;
    }
1176568
public function addHidden($name, $attr = [])
    {
        $e = new \FrenchFrogs\Form\Element\Hidden($name, $attr);
        $this->addElement($e);
        return $e;
    }
20815
public function withTextFromOptions(string $name, string $label, array $valueLabelMap)
    {
        $this->contentGroup->textAreas[$name] = ['name' => $name, 'label' => $label, 'options' => $valueLabelMap, 'order' => $this->order++];

        return $this;
    }
747430
public function createEmailElement($name, $label, $required = false, $multi = false) {
        $options['label']     = $label;
        $options['maxlength'] = 250;
        $options['required']  = $required;
        $options['size']      = 50;

        $element = $this->_form->createElement('text', $name, $options);

        if ($multi) {
            $element->addValidator('SimpleEmails');
        } else {
            $element->addValidator('SimpleEmail');
        }

        return $element;
    }
668804
public function addMultipleSelect(string $name) : Element\Select\MultipleSelect
    {
        $select = new Element\Select\MultipleSelect($this, $name . '[]');
        $this->addComponent($name, $select);

        return $select;
    }
832077
protected function addElement_select ($name, $label, $customElementConfig=array())
    {
        $defaultElementConfig = array(
            'name'       => $name,
            'attributes' => array(
                'id'         => $name,
            ),
            'options'    => array(
                'label'      => $label,
            ),
        );
        $elementConfig = array_replace_recursive(
            $defaultElementConfig,
            $customElementConfig
        );

        $this->addElement_select_configArray($elementConfig);
    }
147323
public function select($field, $label) {
        $select = new Select($this->_entity, $field, $label);
        array_push($this->_elements, $select);

        return $select;
    }
269630
public function addImage($name, $label = '', $width = null, $height = null )
    {
        $e = new \FrenchFrogs\Form\Element\Image($name, $label, $width, $height);
        $this->addElement($e);
        return $e;
    }
1277188
public function addDatetime($name, $label = '', $format = null, $attr = [])
    {
        $c = new Column\Datetime($name, $label, $format, $attr);
        $this->addColumn($c);
        return $c;
    }
18344
public function addCode($name, $label = '', $attr = [])
    {
        $c = new Column\Code($name, $label, $attr);
        $this->addColumn($c);
        return $c;
    }
838679
public function addSelectList(string $name, array $items = []): void
    {
        $options = $this->formOptions['fields'][$name];
        $wrapper = $this->createWrapper();
        $label = '';

        if (isset($options['label']['text'])) {
            $label = $this->createLabel($options['label']['text'], $name);

            unset($options['label']['text']);
        }

        $list = HtmlTag::createElement('select')
            ->set('id', $name)
            ->set('name', $name);

        $caption = '';

        if (isset($options['caption']['text'])) {
            $list->set('aria-describedby', $name . '_caption');
            $caption = $this->createCaption($options['caption']['text'], $name);

            unset($options['caption']['text']);
        }

        foreach ($items as $value => $text) {
            $item[] = $list->addElement('option')
                ->set('value', $value)
                ->text($text);
        }

        $elements = [
            'wrapper' => $wrapper,
            'label'   => $label,
            'list'    => $list,
            'item'    => $item ?? [],
            'caption' => $caption
        ];

        foreach ($elements as $name => $element) {
            $$name = $this->assignOptionsToElement($options, $name, $element);
        }

        $wrapper->addElement($label);
        $wrapper->addElement($list);
        $wrapper->addElement($caption);

        echo $wrapper;
    }
1332461
public function addSingleSelect(string $name) : Element\Select\SingleSelect
    {
        $select = new Element\Select\SingleSelect($this, $name);
        $this->addComponent($name, $select);

        return $select;
    }
319417
public function addText($name, $label = '', $attr = [])
    {
        $c = new Column\Text($name, $label, $attr);
        $this->addColumn($c);
        return $c;
    }
1372552
public function group($label, callable $callback, array $attr=[]){
		if ( $this->unbuffered() ){
			trigger_error("Cannot use Form groups in unbuffered mode", E_USER_ERROR);
		}
		$field = new FormGroup($this->context, $label, $callback, $attr);
		return $this->addField($field);
	}
800044
public function addButton($name, $label, $attr = [] )
    {
        $e = new \FrenchFrogs\Form\Element\Button($name, $label, $attr);
        $this->addElement($e);
        return $e;
    }
986326
public function select($name, array $options, $selected = null, array $attributes = [])
    {
        $tag = new Tag('select', $attributes);
        $tag->name = $name;
        
        if ($selected === null)
            $selected = $this->getDefaultValue($name);

        foreach ($options as $value => $label)
        {
            $option = new Tag('option');
            $option->value = $value;
            $option->setText($label);

            if ($selected !== null && $value == $selected)
                $option->selected = true;

            $tag->addChild($option);
        }

        return $tag;
    }
722182
public function addPre($name, $label = '', $attr = [] )
    {
        $e = new \FrenchFrogs\Form\Element\Pre($name, $label, $attr);
        $this->addElement($e);
        return $e;
    }