public function formField($kwargs = [])
    {
        $fieldClass = ArrayHelper::pop(
            $kwargs,
            'fieldClass',
            \Eddmash\PowerOrm\Form\Fields\CharField::class
        );

        $defaults = [
            'required' => !$this->formBlank,
            'label' => $this->verboseName,
            'helpText' => $this->helpText,
        ];

        if ($this->hasDefault()) {
            $defaults['initial'] = $this->getDefault();
        }

        if ($this->choices) {
            $include_blank = true;

            if ($this->formBlank || empty($this->hasDefault()) || !in_array('initial', $kwargs)) {
                $include_blank = false;
            }

            $defaults['choices'] = $this->getChoices(['include_blank' => $include_blank]);
            $defaults['coerce'] = [$this, 'toPhp'];

            $fieldClass = ArrayHelper::getValue(
                $kwargs,
                'formChoicesClass',
                TypedChoiceField::class
            );
        }

        $defaults = array_merge($defaults, $kwargs);

        return $fieldClass::instance($defaults);
    }
public function formField($kwargs = [])
    {
        $fieldClass = ArrayHelper::pop(
            $kwargs,
            'fieldClass',
            \Eddmash\PowerOrm\Form\Fields\CharField::class
        );

        $defaults = [
            'required' => !$this->formBlank,
            'label' => $this->verboseName,
            'helpText' => $this->helpText,
        ];

        if ($this->hasDefault()) {
            $defaults['initial'] = $this->getDefault();
        }

        if ($this->choices) {
            $include_blank = true;

            if ($this->formBlank || empty($this->hasDefault()) || !in_array('initial', $kwargs)) {
                $include_blank = false;
            }

            $defaults['choices'] = $this->getChoices(['include_blank' => $include_blank]);
            $defaults['coerce'] = [$this, 'toPhp'];

            $fieldClass = ArrayHelper::getValue(
                $kwargs,
                'formChoicesClass',
                TypedChoiceField::class
            );
        }

        $defaults = array_merge($defaults, $kwargs);

        return $fieldClass::instance($defaults);
    }
public function formField ( $ kwargs = [ ] ) { $ fieldClass = ArrayHelper :: pop ( $ kwargs , 'fieldClass' , \ Eddmash \ PowerOrm \ Form \ Fields \ CharField :: class ) ; $ defaults = [ 'required' => ! $ this -> formBlank , 'label' => $ this -> verboseName , 'helpText' => $ this -> helpText , ] ; if ( $ this -> hasDefault ( ) ) { $ defaults [ 'initial' ] = $ this -> getDefault ( ) ; } if ( $ this -> choices ) { $ include_blank = true ; if ( $ this -> formBlank || empty ( $ this -> hasDefault ( ) ) || ! in_array ( 'initial' , $ kwargs ) ) { $ include_blank = false ; } $ defaults [ 'choices' ] = $ this -> getChoices ( [ 'include_blank' => $ include_blank ] ) ; $ defaults [ 'coerce' ] = [ $ this , 'toPhp' ] ; $ fieldClass = ArrayHelper :: getValue ( $ kwargs , 'formChoicesClass' , TypedChoiceField :: class ) ; } $ defaults = array_merge ( $ defaults , $ kwargs ) ; return $ fieldClass :: instance ( $ defaults ) ; }
Returns an Eddmash\PowerOrm\Form\Fields\Field instance that represents this database field.

@param array $kwargs

@return mixed
@author: Eddilbert Macharia (http://eddmash.com)<edd.cowan@gmail.com>
Returns an Eddmash \ PowerOrm \ Form \ Fields \ Field instance that represents this database field .