Short description of method initForm

@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return mixed
495807
public function initForm()
    {
        $this->form = tao_helpers_form_FormFactory::getForm('loginForm');

        $connectElt = tao_helpers_form_FormFactory::getElement('connect', 'Submit');
        $connectElt->setValue(__('Log in'));
        $connectElt->setAttributes(array('disabled' => 'disabled'));
        $connectElt->addClass('disabled');
        $this->form->setActions(array($connectElt), 'bottom');
    }
1183710
private function init()
    {
        $aData = $this->data;

        $this
            // Required value rules
            ->addRule(
                'required',
                function ($sFieldName) use ($aData) {
                    if (\nadir\core\validator\Validator::isIndexSet(
                        $aData,
                        $sFieldName
                    )) {
                        return true;
                    }
                    return false;
                },
                function ($sFieldName) {
                    return "Field '{$sFieldName}' is required.";
                }
            )
            // String rules
            ->addRule(
                'string',
                function ($sFieldName, array $aOpt = array()) use ($aData) {
                    if (\nadir\core\validator\Validator::isIndexSet(
                        $aData,
                        $sFieldName
                    )) {
                        $mValue = \nadir\core\validator\Validator
                        ::getArrayItemByPointSeparatedKey($aData, $sFieldName);
                        if (!is_string($mValue)) {
                            return false;
                        }
                        if (isset($aOpt['notEmpty'])) {
                            $mTmp = trim($mValue);
                            if ($aOpt['notEmpty'] && empty($mTmp)) {
                                return false;
                            }
                            if (!$aOpt['notEmpty'] && !empty($mTmp)) {
                                return false;
                            }
                        }
                        if (isset($aOpt['pattern'])) {
                            if (!preg_match($aOpt['pattern'], $mValue)) {
                                return false;
                            }
                        }
                        if (isset($aOpt['length'])) {
                            $nLength = mb_strlen($mValue, 'UTF-8');
                            if (isset($aOpt['length']['min'])) {
                                if ($nLength < $aOpt['length']['min']) {
                                    return false;
                                }
                            }
                            if (isset($aOpt['length']['max'])) {
                                if ($nLength > $aOpt['length']['max']) {
                                    return false;
                                }
                            }
                            if (isset($aOpt['length']['equal'])) {
                                if ($nLength != $aOpt['length']['equal']) {
                                    return false;
                                }
                            }
                        }
                    }
                    return true;
                },
                function ($sFieldName, array $aOpt = array()) {
                    if (!empty($aOpt)) {
                        $aKeys = array_keys($aOpt);
                        $sKeys = implode(', ', $aKeys);
                        return "Invalid string field '{$sFieldName}' value. "
                        . "Validation options: {$sKeys}";
                    }
                    return "Invalid string field '{$sFieldName}' value.";
                }
            )
            // Number rules
            ->addRule(
                'number',
                function ($sFieldName, array $aOpt = array()) use ($aData) {
                    if (\nadir\core\validator\Validator::isIndexSet(
                        $aData,
                        $sFieldName
                    )) {
                        $mValue = \nadir\core\validator\Validator
                        ::getArrayItemByPointSeparatedKey($aData, $sFieldName);
                        if (!is_numeric($mValue)) {
                            return false;
                        }
                        if (isset($aOpt['float'])) {
                            if ($aOpt['float'] && !is_float($mValue)) {
                                return false;
                            }
                            if (!$aOpt['float'] && is_float($mValue)) {
                                return false;
                            }
                        }
                        if (isset($aOpt['integer'])) {
                            if ($aOpt['integer'] && !is_int($mValue)) {
                                return false;
                            }
                            if (!$aOpt['integer'] && is_int($mValue)) {
                                return false;
                            }
                        }
                        if (isset($aOpt['positive'])) {
                            if ($aOpt['positive'] && $mValue <= 0) {
                                return false;
                            }
                            if (!$aOpt['positive'] && $mValue >= 0) {
                                return false;
                            }
                        }
                        if (isset($aOpt['value'])) {
                            if (isset($aOpt['value']['equal'])) {
                                if ($mValue != $aOpt['value']['equal']) {
                                    return false;
                                }
                            }
                            if (isset($aOpt['value']['min'])) {
                                if ($mValue < $aOpt['value']['min']) {
                                    return false;
                                }
                            }
                            if (isset($aOpt['value']['max'])) {
                                if ($mValue > $aOpt['value']['max']) {
                                    return false;
                                }
                            }
                        }
                    }
                    return true;
                },
                function ($sFieldName, array $aOpt = array()) {
                    if (!empty($aOpt)) {
                        $aKeys = array_keys($aOpt);
                        $sKeys = implode(', ', $aKeys);
                        return "Invalid number field '{$sFieldName}' value. "
                        . "Validation options: {$sKeys}";
                    }
                    return "Invalid number field '{$sFieldName}' value.";
                }
            )
            // Array rules
            ->addRule(
                'array',
                function ($sFieldName, array $aOpt = array()) use ($aData) {
                    if (\nadir\core\validator\Validator::isIndexSet(
                        $aData,
                        $sFieldName
                    )) {
                        $mValue = \nadir\core\validator\Validator
                        ::getArrayItemByPointSeparatedKey($aData, $sFieldName);
                        if (!is_array($mValue)) {
                            return false;
                        }
                        if (isset($aOpt['assoc'])) {
                            $funcIsAssoc = function (array $aArray) {
                                // return false if array is empty
                                return (bool) count(array_filter(
                                    array_keys($aArray),
                                    'is_string'
                                ));
                            };
                            if ($aOpt['assoc'] && !$funcIsAssoc($mValue)) {
                                return false;
                            }
                            if (!$aOpt['assoc'] && $funcIsAssoc($mValue)) {
                                return false;
                            }
                            unset($funcIsAssoc);
                        }
                        if (isset($aOpt['length'])) {
                            $nLength = count($mValue);
                            if (isset($aOpt['length']['min'])) {
                                if ($nLength < $aOpt['length']['min']) {
                                    return false;
                                }
                            }
                            if (isset($aOpt['length']['max'])) {
                                if ($nLength > $aOpt['length']['max']) {
                                    return false;
                                }
                            }
                            if (isset($aOpt['length']['equal'])) {
                                if ($nLength != $aOpt['length']['equal']) {
                                    return false;
                                }
                            }
                        }
                    }
                    return true;
                },
                function ($sFieldName, array $aOpt = array()) {
                    if (!empty($aOpt)) {
                        $aKeys = array_keys($aOpt);
                        $sKeys = implode(', ', $aKeys);
                        return "Invalid array field '{$sFieldName}' value. "
                        . "Validation options: {$sKeys}";
                    }
                    return "Invalid array field '{$sFieldName}' value.";
                }
            )
            // Boolean rules
            ->addRule(
                'boolean',
                function ($sFieldName, array $aOpt = array()) use ($aData) {
                    if (\nadir\core\validator\Validator::isIndexSet(
                        $aData,
                        $sFieldName
                    )) {
                        $mValue = \nadir\core\validator\Validator
                        ::getArrayItemByPointSeparatedKey($aData, $sFieldName);
                        if (!is_bool($mValue)) {
                            return false;
                        }
                        if (isset($aOpt['isTrue'])) {
                            if ($aOpt['isTrue'] && !$mValue) {
                                return false;
                            }
                            if (!$aOpt['isTrue'] && $mValue) {
                                return false;
                            }
                        }
                    }
                    return true;
                },
                function ($sFieldName, array $aOpt = array()) {
                    if (!empty($aOpt)) {
                        $aKeys = array_keys($aOpt);
                        $sKeys = implode(', ', $aKeys);
                        return "Invalid boolean field '{$sFieldName}' value. "
                        . "Validation options: {$sKeys}";
                    }
                    return "Invalid boolean field '{$sFieldName}' value.";
                }
            );
    }
926099
public function init() {
        global $PAGE, $DB;

        $result = new workshop_allocation_result($this);

        $customdata = array();
        $customdata['workshop'] = $this->workshop;

        $current = $DB->get_record('workshopallocation_scheduled',
            array('workshopid' => $this->workshop->id), '*', IGNORE_MISSING);

        $customdata['current'] = $current;

        $this->mform = new workshop_scheduled_allocator_form($PAGE->url, $customdata);

        if ($this->mform->is_cancelled()) {
            redirect($this->workshop->view_url());
        } else if ($settings = $this->mform->get_data()) {
            if (empty($settings->enablescheduled)) {
                $enabled = false;
            } else {
                $enabled = true;
            }
            if (empty($settings->reenablescheduled)) {
                $reset = false;
            } else {
                $reset = true;
            }
            $settings = workshop_random_allocator_setting::instance_from_object($settings);
            $this->store_settings($enabled, $reset, $settings, $result);
            if ($enabled) {
                $msg = get_string('resultenabled', 'workshopallocation_scheduled');
            } else {
                $msg = get_string('resultdisabled', 'workshopallocation_scheduled');
            }
            $result->set_status(workshop_allocation_result::STATUS_CONFIGURED, $msg);
            return $result;
        } else {
            // this branch is executed if the form is submitted but the data
            // doesn't validate and the form should be redisplayed
            // or on the first display of the form.

            if ($current !== false) {
                $data = workshop_random_allocator_setting::instance_from_text($current->settings);
                $data->enablescheduled = $current->enabled;
                $this->mform->set_data($data);
            }

            $result->set_status(workshop_allocation_result::STATUS_VOID);
            return $result;
        }
    }
480093
public function Form()
    {
        $form = new Form(
            $this,
            'SilverStripe\\Forms\\Form',
            new FieldList($root = new TabSet('Root', new Tab('Main'))),
            new FieldList()
        );

        if ($this->getTopLevelController() instanceof LeftAndMain) {
            $form->setTemplate('LeftAndMain_EditForm');
            $form->addExtraClass('cms-content cms-edit-form cms-tabset center');
            $form->setAttribute('data-pjax-fragment', 'CurrentForm Content');

            $root->setTemplate('CMSTabSet');
            $form->Backlink = $this->getBackLink();
        }

        return $form;
    }
1218556
public function initForm()
	{
		$this->form = tao_helpers_form_FormFactory::getForm('import');
	    
		$this->form->setActions(is_null($this->subForm) ? array() : $this->subForm->getActions('top'), 'top');
	    $this->form->setActions(is_null($this->subForm) ? array() : $this->subForm->getActions('bottom'), 'bottom');
				 
	}
927681
private function initialize()
    {
        $this->fields = new FormFieldRegistry();

        $xpath = new \DOMXPath($this->node->ownerDocument);

        // add submitted button if it has a valid name
        if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) {
            if ('input' == $this->button->nodeName && 'image' == strtolower($this->button->getAttribute('type'))) {
                $name = $this->button->getAttribute('name');
                $this->button->setAttribute('value', '0');

                // temporarily change the name of the input node for the x coordinate
                $this->button->setAttribute('name', $name.'.x');
                $this->set(new Field\InputFormField($this->button));

                // temporarily change the name of the input node for the y coordinate
                $this->button->setAttribute('name', $name.'.y');
                $this->set(new Field\InputFormField($this->button));

                // restore the original name of the input node
                $this->button->setAttribute('name', $name);
            } else {
                $this->set(new Field\InputFormField($this->button));
            }
        }

        // find form elements corresponding to the current form
        if ($this->node->hasAttribute('id')) {
            // corresponding elements are either descendants or have a matching HTML5 form attribute
            $formId = Crawler::xpathLiteral($this->node->getAttribute('id'));

            $fieldNodes = $xpath->query(sprintf('( descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)] )[not(ancestor::template)]', $formId));
            foreach ($fieldNodes as $node) {
                $this->addField($node);
            }
        } else {
            // do the xpath query with $this->node as the context node, to only find descendant elements
            // however, descendant elements with form attribute are not part of this form
            $fieldNodes = $xpath->query('( descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)] )[not(ancestor::template)]', $this->node);
            foreach ($fieldNodes as $node) {
                $this->addField($node);
            }
        }

        if ($this->baseHref && '' !== $this->node->getAttribute('action')) {
            $this->currentUri = $this->baseHref;
        }
    }
1057693
public function init()
	{
		if (!isset($this->form))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Form is not set.');

		if (!isset($this->model))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Model is not set.');

		if (!isset($this->type))
			throw new CException(__CLASS__ . ': Failed to initialize widget! Input type is not set.');

		if ($this->type === self::TYPE_UNEDITABLE)
		{
			if (isset($this->htmlOptions['class']))
				$this->htmlOptions['class'] .= ' uneditable-input';
			else
				$this->htmlOptions['class'] = 'uneditable-input';
		}

		$this->processHtmlOptions();
	}
1276117
protected function initForm()
    {
    	parent::initForm();
    	
    	$this->form->setName($this->formName);
    	
		$actions = tao_helpers_form_FormFactory::getCommonActions('top');
		$this->form->setActions($actions, 'top');
		$this->form->setActions($actions, 'bottom');
    }
259434
protected function createComponentEditForm(): Form
	{
		$form = $this->formFactory->create();

		$form->addText('name', 'default.name')
			->setRequired();

		if ($this->editConst) {
			$form->addText('const', 'webManager.web.content.const')
				->setRequired();

			$form->addSelectUntranslated('locale', 'webManager.web.pages.locale')
				->setItems($this->localeService->allowed);
		}

		$form->addText('title', 'webManager.web.content.contentTitle')
			->addRule(Form::MAX_LENGTH, null, 150)
			->setRequired(false);

		$form->addTextArea('keywords', 'webManager.web.content.keywords');

		$form->addImageUpload('image', 'webManager.web.content.photo', 'webManager.web.content.photoDelete')
			->setNamespace('content')
			->setPreview('300x100');

		$form->addColor('background', 'webManager.web.content.background');

		$form->addTextArea('description', 'webManager.web.content.description');

		$form->addTextEditor('content', 'webManager.web.content.content');

		$form->addSubmit('save', 'form.save');

		$form->addLink('back', 'form.back', $this->getBacklink());

		$form->onSuccess[] = [$this, 'editFormSucceeded'];

		return $form;
	}
1277855
protected function InitForm()
    {
        $this->submit = $this->LoadElement();
        
        $this->AddNameField();
        $this->AddValueField();
        
        $this->AddCssIDField();
        $this->AddCssClassField();
        $this->AddTemplateField();
        $this->AddSubmit();
    }
547879
public function init() {

        parent::init();

		// Permission
        $this->crudPermission = FormsGlobal::PERM_FORM_ADMIN;

		// Config
		$this->apixBase = 'forms/form/submit';

		// Services
		$this->modelService = Yii::$app->factory->get( 'formSubmitService' );
		$this->formService = Yii::$app->factory->get( 'formService' );

		// Sidebar
		$this->sidebar = [ 'parent' => 'sidebar-form', 'child' => 'form' ];

		// Return Url
		$this->returnUrl = Url::previous( 'form-submits' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/forms/form/submit/all' ], true );

		// All Url
		$allUrl = Url::previous( 'forms' );
		$allUrl = isset( $allUrl ) ? $allUrl : Url::toRoute( [ '/forms/form/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs = [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ],
				[ 'label' => 'Forms', 'url' =>  $allUrl ]
			],
			'all' => [ [ 'label' => 'Form Submit' ] ],
			'create' => [ [ 'label' => 'Form Submit', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Form Submit', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Form Submit', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
			'items' => [ [ 'label' => 'Form Submit', 'url' => $this->returnUrl ], [ 'label' => 'Items' ] ]
		];
	}
110212
public function initElements()
    {
        

    	$labelElt = tao_helpers_form_FormFactory::getElement('label', 'Textbox');
		$labelElt->setDescription(__('Name'));
		$labelElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
		$this->form->addElement($labelElt);

		$sizeElt = tao_helpers_form_FormFactory::getElement('size', 'Textbox');
		$sizeElt->setDescription(__('Number of elements'));
		$sizeElt->setAttribute('size', '4');
		$sizeElt->setValue(1);
		$sizeElt->addValidators(array(
			tao_helpers_form_FormFactory::getValidator('NotEmpty'),
			tao_helpers_form_FormFactory::getValidator('Integer', array('min' => 1))
		));
		$this->form->addElement($sizeElt);
    }
1223787
protected function _prepareForm()
    {
        $form = $this->formFactory->create();
        $this->setForm($form);

        /** @var \Mirasvit\Blog\Model\Post $post */
        $post = $this->registry->registry('current_model');

        $fieldset = $form->addFieldset('categories_fieldset', [
            'class'  => 'blog__post-fieldset',
            'legend' => __('Categories'),
        ]);

        $collection = $this->categoryCollectionFactory->create()
            ->addAttributeToSelect(['name']);

        $fieldset->addField('category_ids', 'checkboxes', [
            'name'   => 'post[category_ids][]',
            'value'  => $post->getCategoryIds(),
            'values' => $collection->toOptionArray()
        ]);

        return parent::_prepareForm();
    }
607355
private function generateForm()
    {
        // Generate Form Component class
        $controllerInstance = Controller::instance($this->columns, null, $this);

        $formTemplateDir =
            dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Form'.DS;

        $form = new Form($controllerInstance, $this);
        $form->setFormTemplatePath($formTemplateDir);

        $form->generate();
    }
538430
public function init() {

        parent::init();

		// Views
		$this->setViewPath( '@cmsgears/module-core/admin/views/config' );

		// Permission
		$this->crudPermission = FormsGlobal::PERM_FORM_ADMIN;

		// Config
		$this->type		= CoreGlobal::TYPE_SYSTEM;
		$this->apixBase = 'core/form';
		$this->submits	= false;

		// Services
		$this->modelService = Yii::$app->factory->get( 'cmsgears\core\common\services\interfaces\resources\IFormService' );

		// Sidebar
		$this->sidebar = [ 'parent' => 'sidebar-form', 'child' => 'config' ];

		// Return Url
		$this->returnUrl = Url::previous( 'configs' );
		$this->returnUrl = isset( $this->returnUrl ) ? $this->returnUrl : Url::toRoute( [ '/forms/config/all' ], true );

		// Breadcrumbs
		$this->breadcrumbs = [
			'base' => [
				[ 'label' => 'Home', 'url' => Url::toRoute( '/dashboard' ) ]
			],
			'all' => [ [ 'label' => 'Forms' ] ],
			'create' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Add' ] ],
			'update' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Update' ] ],
			'delete' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Delete' ] ],
			'fields' => [ [ 'label' => 'Forms', 'url' => $this->returnUrl ], [ 'label' => 'Fields' ] ]
		];
	}
20823
public function init() {
        global $PAGE;

        $result = new workshop_allocation_result($this);
        $customdata = array();
        $customdata['workshop'] = $this->workshop;
        $this->mform = new workshop_random_allocator_form($PAGE->url, $customdata);
        if ($this->mform->is_cancelled()) {
            redirect($this->workshop->view_url());
        } else if ($settings = $this->mform->get_data()) {
            $settings = workshop_random_allocator_setting::instance_from_object($settings);
            $this->execute($settings, $result);
            return $result;
        } else {
            // this branch is executed if the form is submitted but the data
            // doesn't validate and the form should be redisplayed
            // or on the first display of the form.
            $result->set_status(workshop_allocation_result::STATUS_VOID);
            return $result;
        }
    }
1289001
protected function _FromForm() {
      $Form = new Gdn_Form();
      $Px = $this->Prefix;

      $Types = (array)$Form->GetFormValue($Px.'Type', array());
      $PermissionFields = (array)$Form->GetFormValue($Px.'PermissionField', array());
      $RoleFields = (array)$Form->GetFormValue($Px.'RoleField', array());
      $Fields = (array)$Form->GetFormValue($Px.'Field', array());
      $Expressions = (array)$Form->GetFormValue($Px.'Expr', array());

      $Conditions = array();
      for ($i = 0; $i < count($Types) - 1; $i++) { // last condition always template row.

         $Condition = array($Types[$i]);
         switch ($Types[$i]) {
            case Gdn_Condition::PERMISSION:
               $Condition[1] = GetValue($i, $PermissionFields, '');
               break;
            case Gdn_Condition::REQUEST:
               $Condition[1] = GetValue($i, $Fields, '');
               $Condition[2] = GetValue($i, $Expressions, '');
               break;
            case Gdn_Condition::ROLE:
               $Condition[1] = GetValue($i, $RoleFields);
               break;
            case '':
               $Condition[1] = '';
               break;
            default:
               continue;
         }
         $Conditions[] = $Condition;
      }
      return $Conditions;
   }