src/Shop/BaseConfigForm.php
protected function getOptionsOrHiddenField($name, $type, $required = true, array $options = null)
    {
        if ($options === null) {
            $methodName = 'get' . ucfirst($name) . 'Options';
            $options = $this->shopCapabilities->$methodName();
        }
        if (count($options) === 1) {
            // Make it a hidden field.
            $field = array(
                'type' => 'hidden',
                'value' => reset($options),
            );
        } else {
            $field = array(
                'type' => $type,
                'label' => $this->t("field_$name"),
                'description' => $this->t($this->t("desc_$name")),
                'options' => $options,
                'attributes' => array(
                    'required' => $required,
                ),
            );
        }
        return $field;
    }
protected function getOptionsOrHiddenField($name, $type, $required = true, array $options = null)
    {
        if ($options === null) {
            $methodName = 'get' . ucfirst($name) . 'Options';
            $options = $this->shopCapabilities->$methodName();
        }
        if (count($options) === 1) {
            // Make it a hidden field.
            $field = array(
                'type' => 'hidden',
                'value' => reset($options),
            );
        } else {
            $field = array(
                'type' => $type,
                'label' => $this->t("field_$name"),
                'description' => $this->t($this->t("desc_$name")),
                'options' => $options,
                'attributes' => array(
                    'required' => $required,
                ),
            );
        }
        return $field;
    }
protected function getOptionsOrHiddenField ( $ name , $ type , $ required = true , array $ options = null ) { if ( $ options === null ) { $ methodName = 'get' . ucfirst ( $ name ) . 'Options' ; $ options = $ this -> shopCapabilities -> $ methodName ( ) ; } if ( count ( $ options ) === 1 ) { // Make it a hidden field. $ field = array ( 'type' => 'hidden' , 'value' => reset ( $ options ) , ) ; } else { $ field = array ( 'type' => $ type , 'label' => $ this -> t ( "field_$name" ) , 'description' => $ this -> t ( $ this -> t ( "desc_$name" ) ) , 'options' => $ options , 'attributes' => array ( 'required' => $ required , ) , ) ; } return $ field ; }
Creates a hidden or an option field

If there is only 1 option, a hidden value with a fixed value will be
created, an option field that gives the user th choice otherwise.

@param string $name
The field name.
@param string $type
The field type: radio or select.
@param bool $required
Whether the required attribute should be rendered.
@param array|null $options
An array with value =>label pairs that can be used as an option set.
If null, a similarly as $name named method on $this->shopCapabilities
wil be called to get the options.

@return array
A form field definition.
Creates a hidden or an option field