Factors an instance of Form

@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@param  string $name
@param  array $options
@return tao_helpers_form_Form
@throws common_Exception
356463
public static function getForm($name = '', array $options = array())
    {
        $returnValue = null;

        
		
		//use the right implementation (depending the render mode)
		//@todo refactor this and use a FormElementFactory
		switch(self::$renderMode){
			case 'xhtml':
				
				$myForm = new tao_helpers_form_xhtml_Form($name, $options);
				
				$myForm->setDecorators(array(
					'element'			=> new tao_helpers_form_xhtml_TagWrapper(array('tag' => 'div')),
					'group'				=> new tao_helpers_form_xhtml_TagWrapper(array('tag' => 'div', 'cssClass' => 'form-group')),
					'error'				=> new tao_helpers_form_xhtml_TagWrapper(array('tag' => 'div', 'cssClass' => 'form-error')),
					'actions-bottom'	=> new tao_helpers_form_xhtml_TagWrapper(array('tag' => 'div', 'cssClass' => 'form-toolbar')),
					//'actions-top'		=> new tao_helpers_form_xhtml_TagWrapper(array('tag' => 'div', 'cssClass' => 'form-toolbar'))
				));
				
				$myForm->setActions(self::getCommonActions(), 'bottom');
				
				break;
			
			default: 
				throw new common_Exception("render mode {self::$renderMode} not yet supported");
		}
		
		$returnValue = $myForm;
		
        

        return $returnValue;
    }
603238
public function selectTag($name, $options, array $attrs = [])
    {
        # This is found also in Form::select()
        if (!is_string($options)) {
            if (is_array($options) && ArrayTools::isIndexed($options) && count($options) == 2)
                list ($options, $value) = $options;
            else
                $value = null;
            $options = $this->optionsForSelect($options, $value);
        }
        
        if (isset($attrs['prompt'])) {
            $options = $this->contentTag('option', $attrs['prompt'], ['value' => '', 'allow_blank_attrs' => true]) . "\n" . $options;
            unset($attrs['prompt']);
        }
        $attrs['value'] = $attrs['type'] = null;
        
        $select_tag = $this->_form_field_tag('select', $name, $options, $attrs, true);
        return $select_tag;
    }
259786
private function createTab(FormBuilderInterface $builder, $name, $options = array())
    {
        $options = array_replace(
            $options,
            array(
                'inherit_data' => true,
            ));

        return $builder->create($name, TabsTabType::class, $options);
    }
138679
static function laraform($name = '', $options) {
        $gr = new ElementGroupRadioButtonTwbs();
        $gr->setAttribute('data-toggle', 'buttons');
        foreach ($options as $k => $v) {
            $gr->putRadioTwbs($name, $k)
                ->setAttribute('autocomplete', 'off')
                ->setLabel($v);
        }
        return $gr;
    }
1040197
public function choice(string $name, array $options = []): FieldTypeInterface
    {
        return (new ChoiceType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
279480
public function getCheckbox($name, array $options=[]) {
		$choices = $this->getChoices();
		$default = $this->value;

		$value = isset($options['value']) ? $options['value']:null;
		if($value===null) {
			foreach($choices as $k=>$v) {
				if($v == $name) {
					$value = $k;
					break;
				}
			}
		}
		if($value === null)
			throw new \Exception('No value for checkbox '.$name);

		if(in_array($value, $default))
			$options['attrs']['checked'] = 'checked';
		$options['label'] = $name;

		return $this->getTopForm()->getWidget('checkbox', $this->name.'[]', $value, $options);
	}
1099285
public function createCollection($name, array $options = [])
    {
        return $this->bridge->createCollection($this->cName($name), $options);
    }
1294340
public static function fa ($name, $options = [])
		{
			if (!isset($options[ 'class' ]))
				$options[ 'class' ] = '';
			$options[ 'class' ] = trim($options[ 'class' ] . ' fa fa-' . $name);

			return self::tag('i', '', $options);
		}
1267070
protected function getOptionsList($name, $options)
    {
        if (empty($options)) {
            $options = $this->getOptionsFromModel($name);
        }

        return $options;
    }
122529
public function password($name, array $options = [])
    {
        return $this->form->password($name,
                                     $this->addFormControlClass($this->getFieldOptions($name, $options)));
    }
1280831
protected function getForm($name = null, $option = null){
		if (!$name) {
			$name = $this->getName();
		}
		$frmCls = $this->getFormClass($option);
		$form = $this->getServiceLocator()->get('FormElementManager')->get($frmCls);
		return $form;
	}
1207887
public static function make($name, array $options = []): self
    {
        $class = new ReflectionClass($options['class'] ?? static::class);

        /* @var static $instance */
        $instance = $class->newInstanceWithoutConstructor();
        $instance->setName($name);
        $instance->setOptions($options);

        return $instance;
    }
1177308
public function AdCKEditor($name,$options = array())
    {
        $CKEditor = new \AdfabCore\Service\CKEditor();

        $CKEditor->returnOutput = true;

        /*
         * General module configurations
         */
        if(isset($this->Config['BasePath']))	$CKEditor->basePath 			= $this->Config['BasePath'].'/';
        if(isset($this->Config['Toolbar']))		$CKEditor->config['toolbar']    = $this->Config['Toolbar'];
        if(isset($this->Config['Width']))       $CKEditor->config['width']      = $this->Config['Width'];
        if(isset($this->Config['Height']))      $CKEditor->config['height']     = $this->Config['Height'];
        if(isset($this->Config['Language']))    $CKEditor->config['language']   = $this->Config['Language'];
        if(isset($this->Config['Color']))       $CKEditor->config['uiColor']    = $this->Config['Color'];
        if(isset($this->Config['stylesSet']))   $CKEditor->config['stylesSet']  = $this->Config['stylesSet'];
		if(isset($this->Config['contentsCss'])) $CKEditor->config['contentsCss']= $this->Config['contentsCss'];
        if(isset($this->Config['templates_files']))   $CKEditor->config['templates_files']  = $this->Config['templates_files'];

        // El Finder
        if(isset($this->Config['ElFinderBaseURL']))      $CKEditor->config['filebrowserBrowseUrl']    = $this->Config['ElFinderBaseURL'];
        if(isset($this->Config['ElFinderWindowWidth']))  $CKEditor->config['filebrowserWindowWidth']  = $this->Config['ElFinderWindowWidth'];
        if(isset($this->Config['ElFinderWindowHeight'])) $CKEditor->config['filebrowserWindowHeight'] = $this->Config['ElFinderWindowHeight'];

        /*
         * special confirmations in your form
         */
        if(isset($options['BasePath']))	 $CKEditor->basePath		    = $options['BasePath'].'/';
        if(isset($options['Toolbar']))   $CKEditor->config['toolbar']   = $options['Toolbar'];
        if(isset($options['toolbar']))   $CKEditor->config['toolbar']   = $options['toolbar'];
        if(isset($options['Width']))     $CKEditor->config['width']     = $options['Width'];
        if(isset($options['Height']))    $CKEditor->config['height']    = $options['Height'];
        if(isset($options['Language']))  $CKEditor->config['language']  = $options['Language'];
        if(isset($options['Color']))     $CKEditor->config['uiColor']   = $options['uiColor'];
        if(isset($options['stylesSet'])) $CKEditor->config['stylesSet'] = $options['stylesSet'];
        if(isset($options['contentsCss'])) $CKEditor->config['contentsCss'] = $options['contentsCss'];
        if(isset($options['templates_files']))   $CKEditor->config['templates_files']  = $options['templates_files'];

        // El Finder
        if(isset($options['ElFinderBaseURL']))           $CKEditor->config['filebrowserBrowseUrl']    = $options['ElFinderBaseURL'];
        if(isset($options['ElFinderWindowWidth']))       $CKEditor->config['filebrowserWindowWidth']  = $options['ElFinderWindowWidth'];
        if(isset($options['ElFinderWindowHeight']))      $CKEditor->config['filebrowserWindowHeight'] = $options['ElFinderWindowHeight'];

        echo $CKEditor->replace($name);
    }
993291
public function createCollection($name, $options = [])
    {
        try {
            if (isset($options['capped'])) {
                $options['capped'] = (bool) $options['capped'];
            }

            $this->db->createCollection($name, $options);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            return false;
        }

        return $this->selectCollection($name);
    }
923134
public function email(string $name, array $options = []): FieldTypeInterface
    {
        return (new EmailType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
1240300
public function integer(string $name, array $options = []): FieldTypeInterface
    {
        return (new IntegerType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
127970
protected function getFormGroupOptions($name = null, array $options = [])
    {
        $class = 'form-group';

        if ($name) {
            $class .= ' ' . $this->getFieldErrorClass($name);
        }

        return array_merge(['class' => $class], $options);
    }