Prepare form properties values to be saved.
Remove form fields for password and create a new one with encrypted value.

@return array
510198
protected function prepareValuesToSave()
    {
        $values = parent::prepareValuesToSave();
        if ($this->changePassword) {
            $password = null;
            foreach ($this->formProperties as $key => $property) {
                if ($property['uri'] == GenerisRdf::PROPERTY_USER_PASSWORD && isset($this->formProperties[$key]['formValue'])) {
                    $password = $this->formProperties[$key]['formValue'];
                    break;
                }
            }

            $values[GenerisRdf::PROPERTY_USER_PASSWORD] = core_kernel_users_Service::getPasswordHash()->encrypt($password);
        }

        return $values;
    }
758315
protected function prepareAttributes()
    {

        // initialize the values that has to be updated
        $updatedAt = date('Y-m-d H:i:s');
        $path = $this->getValue(ColumnKeys::PATH);

        // prepare and return the array with the updated values
        return array(
            MemberNames::PATH           => $path,
            MemberNames::UPDATED_AT     => $updatedAt
        );
    }
1308158
protected function prepareVars()
    {
        if ($this->formField->disabled) {
            $this->previewMode = true;
        }

        if ($this->previewMode) {
            $this->useCaption = false;
        }

        $this->vars['fileList'] = $fileList = $this->getFileList();
        $this->vars['singleFile'] = $fileList->first();
        $this->vars['displayMode'] = $this->getDisplayMode();
        $this->vars['emptyIcon'] = $this->getConfig('emptyIcon', 'icon-upload');
        $this->vars['imageHeight'] = $this->imageHeight;
        $this->vars['imageWidth'] = $this->imageWidth;
        $this->vars['acceptedFileTypes'] = $this->getAcceptedFileTypes(true);
        $this->vars['cssDimensions'] = $this->getCssDimensions();
        $this->vars['cssBlockDimensions'] = $this->getCssDimensions('block');
        $this->vars['useCaption'] = $this->useCaption;
        $this->vars['prompt'] = $this->getPromptText();
    }
101544
protected function prepareJsAttributes()
    {
        $attributes = [];
        foreach ($this->columns as $column) {
            $model = $column->getModel();
            $inputID = str_replace(['-0', '-0-'], '', $column->getElementId(0));
            if ($this->form instanceof ActiveForm && $model instanceof Model) {
                $field = $this->form->field($model, $column->name);
                foreach ($column->attributeOptions as $name => $value) {
                    if ($field->hasProperty($name)) {
                        $field->$name = $value;
                    }
                }
                $field->render('');
                $attributeOptions = array_pop($this->form->attributes);
                if (isset($attributeOptions['name']) && $attributeOptions['name'] === $column->name) {
                    $attributes[$inputID] = ArrayHelper::merge($attributeOptions, $column->attributeOptions);
                } else {
                    $this->form->attributes[] = $attributeOptions;
                }
            } else {
                $attributes[$inputID] = $column->attributeOptions;
            }
        }

        return $attributes;
    }
838203
public function create_config()
    {
        $config = array();

        foreach ($this->config as $prop => $default) {
            $is_default = !isset($_POST["_$prop"]);
            $value      = !$is_default || $this->bool_config_props[$prop] ? $_POST["_$prop"] : $default;

            // always disable installer
            if ($prop == 'enable_installer') {
                $value = false;
            }

            // reset useragent to default (keeps version up-to-date)
            if ($prop == 'useragent' && stripos($value, 'Roundcube Webmail/') !== false) {
                $value = $this->defaults[$prop];
            }

            // generate new encryption key, never use the default value
            if ($prop == 'des_key' && $value == $this->defaults[$prop]) {
                $value = rcube_utils::random_bytes(24);
            }

            // convert some form data
            if ($prop == 'debug_level' && !$is_default) {
                if (is_array($value)) {
                    $val = 0;
                    foreach ($value as $dbgval) {
                        $val += intval($dbgval);
                    }
                    $value = $val;
                }
            }
            else if ($prop == 'db_dsnw' && !empty($_POST['_dbtype'])) {
                if ($_POST['_dbtype'] == 'sqlite') {
                    $value = sprintf('%s://%s?mode=0646', $_POST['_dbtype'],
                        $_POST['_dbname']{0} == '/' ? '/' . $_POST['_dbname'] : $_POST['_dbname']);
                }
                else if ($_POST['_dbtype']) {
                    $value = sprintf('%s://%s:%s@%s/%s', $_POST['_dbtype'],
                        rawurlencode($_POST['_dbuser']), rawurlencode($_POST['_dbpass']), $_POST['_dbhost'], $_POST['_dbname']);
                }
            }
            else if ($prop == 'smtp_auth_type' && $value == '0') {
                $value = '';
            }
            else if ($prop == 'default_host' && is_array($value)) {
                $value = self::_clean_array($value);
                if (count($value) <= 1) {
                    $value = $value[0];
                }
            }
            else if ($prop == 'mail_pagesize' || $prop == 'addressbook_pagesize') {
                $value = max(2, intval($value));
            }
            else if ($prop == 'smtp_user' && !empty($_POST['_smtp_user_u'])) {
                $value = '%u';
            }
            else if ($prop == 'smtp_pass' && !empty($_POST['_smtp_user_u'])) {
                $value = '%p';
            }
            else if (is_bool($default)) {
                $value = (bool) $value;
            }
            else if (is_numeric($value)) {
                $value = intval($value);
            }
            else if ($prop == 'plugins' && !empty($_POST['submit'])) {
                $value = array();
                foreach (array_keys($_POST) as $key) {
                    if (preg_match('/^_plugins_*/', $key)) {
                        array_push($value, $_POST[$key]);
                    }
                }
            }

            // skip this property
            if ($value == $this->defaults[$prop]
                && (!in_array($prop, $this->local_config)
                    || in_array($prop, array_merge($this->obsolete_config, array_keys($this->replaced_config)))
                    || preg_match('/^db_(table|sequence)_/', $prop)
                )
            ) {
                continue;
            }

            // save change
            $this->config[$prop] = $value;
            $config[$prop]       = $value;
        }

        $out = "<?php\n\n";
        $out .= "/* Local configuration for Roundcube Webmail */\n\n";

        foreach ($config as $prop => $value) {
            // copy option descriptions from existing config or defaults.inc.php
            $out .= $this->comments[$prop];
            $out .= "\$config['$prop'] = " . self::_dump_var($value, $prop) . ";\n\n";
        }

        return $out;
    }
774800
public function getSaveableFields(): array
    {
        return Hash::apply($this->config('fields'), '{*}[saveable=true]', function ($array) {
            $formatted = [];
            foreach ($array as $data) {
                $formatted[$data['name']] = $data;
            }

            return $formatted;
        });
    }
994550
protected static function define_properties() {
        return array(
            'name' => array(
                'type' => PARAM_TEXT
            ),
            'image' => array(
                'type' => PARAM_URL,
                'null' => NULL_ALLOWED,
                'default' => null
            ),
            'clientid' => array(
                'type' => PARAM_RAW_TRIMMED,
                'default' => ''
            ),
            'clientsecret' => array(
                'type' => PARAM_RAW_TRIMMED,
                'default' => ''
            ),
            'baseurl' => array(
                'type' => PARAM_URL,
                'default' => ''
            ),
            'enabled' => array(
                'type' => PARAM_BOOL,
                'default' => true
            ),
            'showonloginpage' => array(
                'type' => PARAM_BOOL,
                'default' => false
            ),
            'basicauth' => array(
                'type' => PARAM_BOOL,
                'default' => false
            ),
            'scopessupported' => array(
                'type' => PARAM_RAW,
                'null' => NULL_ALLOWED,
                'default' => null
            ),
            'loginscopes' => array(
                'type' => PARAM_RAW,
                'default' => 'openid profile email'
            ),
            'loginscopesoffline' => array(
                'type' => PARAM_RAW,
                'default' => 'openid profile email'
            ),
            'loginparams' => array(
                'type' => PARAM_RAW,
                'default' => ''
            ),
            'loginparamsoffline' => array(
                'type' => PARAM_RAW,
                'default' => ''
            ),
            'alloweddomains' => array(
                'type' => PARAM_RAW,
                'default' => ''
            ),
            'sortorder' => array(
                'type' => PARAM_INT,
                'default' => 0,
            ),
            'requireconfirmation' => array(
                'type' => PARAM_BOOL,
                'default' => true
            )
        );
    }
1110152
protected function _prepareForm()
    {
        $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
        $model = $this->_coreRegistry->registry('row_data');
        $form = $this->_formFactory->create(
            ['data' => [
                            'id' => 'edit_form', 
                            'enctype' => 'multipart/form-data', 
                            'action' => $this->getData('action'), 
                            'method' => 'post'
                        ]
            ]
        );

        // Prepare CSS
        $fieldsCss = 'width:100%;';
        $readOnlyCss = 'color:#777777;background-color:#dddddd;';
        
        // HTML prefix
        $form->setHtmlIdPrefix('ckom2_grid_');

        // Freeze in edit mode state
        $freezeInEditMode = false;
        $freezeInNewMode = false;

        // Build the form
        if ($model->getEntityId()) {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __('Editing subscription : %1', $model->getTrackId()), 'class' => 'fieldset-wide']
            );

            // Add id field
            $fieldset->addField('id', 'hidden', ['name' => 'id']);

            // Set the frozen field state
            $freezeInEditMode = true;

        } else {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __('Adding Subscription'), 'class' => 'fieldset-wide']
            );

            // Set the frozen field state
            $freezeInNewMode = true;
        }

        $fieldset->addField(
            'subscription_status',
            'select',
            [
                'name' => 'subscription_status',
                'label' => __('Status'),
                'id' => 'subscription_status',
                'title' => __('Status'),
                'values' => $this->_statusOptions->getOptionArray(),
                'class' => 'status',
                'required' => true,
                'disabled' => $freezeInNewMode,
                'style' => $fieldsCss . (($freezeInNewMode) ? $readOnlyCss : ''),
            ]
        );

        $fieldset->addField(
            'start_date',
            'date',
            [
                'name' => 'start_date',
                'label' => __('Start date'),
                'id' => 'start_date',
                'title' => __('Start date'),
                'class' => 'required-entry',
                'required' => true,
                'date_format' => 'yyyy-MM-dd',
                'time_format' => 'hh:mm:ss',
                'style' => $fieldsCss,
            ]
        );

        $fieldset->addField(
            'card_id',
            'select',
            [
                'name' => 'card_id',
                'label' => __('Payment method'),
                'id' => 'card_id',
                'title' => __('Payment method'),
                'values' => $this->_userCardsOptions->getOptions(),
                'class' => 'required-entry',
                'required' => true,
                'style' => $fieldsCss,
                'after_element_html' => '<div></div>',
            ]
        );

        $fieldset->addField(
            'track_id',
            'text',
            [
                'name' => 'track_id',
                'label' => __('Track ID'),
                'id' => 'track_id',
                'title' => __('Track ID'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss. $readOnlyCss,
            ]
        );
        
        $fieldset->addField(
            'plan_id',
            'select',
            [
                'name' => 'plan_id',
                'label' => __('Payment plan'),
                'id' => 'track_id',
                'title' => __('Payment plan'),
                'values' => $this->_paymentPlanOptions->getOptionArray(),
                'class' => 'required-entry',
                'required' => true,
                'disabled' => $freezeInEditMode,
                'style' => $fieldsCss . (($freezeInEditMode) ? $readOnlyCss : ''),
            ]
        );

        $fieldset->addField(
            'user_id',
            'select',
            [
                'name' => 'user_id',
                'label' => __('Customer'),
                'id' => 'user_id',
                'title' => __('Customer'),
                'values' => $this->_userListOptions->getOptionArray(),
                'class' => 'required-entry',
                'required' => true,
                'disabled' => $freezeInEditMode,
                'style' => $fieldsCss . (($freezeInEditMode) ? $readOnlyCss : ''),
            ]
        );

        $fieldset->addField(
            'recurring_count_left',
            'text',
            [
                'name' => 'recurring_count_left',
                'label' => __('Recurring count left'),
                'id' => 'recurring_count_left',
                'title' => __('Recurring count left'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss. $readOnlyCss,
                'after_element_html' => $this->_renderTooltip('Number of transactions remaining in the recurring plan.'),
            ]
        );

        $fieldset->addField(
            'total_collection_count',
            'text',
            [
                'name' => 'total_collection_count',
                'label' => __('Total collection count'),
                'id' => 'total_collection_count',
                'title' => __('Total collection count'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss. $readOnlyCss,
                'after_element_html' => $this->_renderTooltip('Total number of transactions that will be applied against the card.'),
            ]
        );

        $fieldset->addField(
            'total_collection_value',
            'text',
            [
                'name' => 'total_collection_value',
                'label' => __('Total collection value'),
                'id' => 'total_collection_value',
                'title' => __('Total collection value'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss. $readOnlyCss,
                'after_element_html' => $this->_renderTooltip('Total value of transactions that will be applied against the card.'),
            ]
        );

        $fieldset->addField(
            'previous_recurring_date',
            'text',
            [
                'name' => 'previous_recurring_date',
                'label' => __('Previous recurring date'),
                'id' => 'previous_recurring_date',
                'title' => __('Previous recurring date'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss. $readOnlyCss,
                'after_element_html' => $this->_renderTooltip('Date of last recurring transaction in "YYYY-MM-DD" format.'),
            ]
        );

        $fieldset->addField(
            'next_recurring_date',
            'text',
            [
                'name' => 'next_recurring_date',
                'label' => __('Next recurring date'),
                'id' => 'next_recurring_date',
                'title' => __('Next recurring date'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss. $readOnlyCss,
                'after_element_html' => $this->_renderTooltip('Date of the next recurring transaction in "YYYY-MM-DD" format. This is especially useful when the merchant has applied a double recurring plan.'),
            ]
        );

        $fieldset->addField(
            'created_at',
            'text',
            [
                'name' => 'created_at',
                'label' => __('Created'),
                'id' => 'recurring_count',
                'title' => __('Created'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss . $readOnlyCss,
            ]
        );

        $fieldset->addField(
            'updated_at',
            'text',
            [
                'name' => 'updated_at',
                'label' => __('Updated'),
                'id' => 'updated_at',
                'title' => __('Updated'),
                'placeholder' => __('Generated automatically'),
                'readonly' => true,
                'style' => $fieldsCss . $readOnlyCss,
            ]
        );

        $form->setValues($model->getData());
        $form->setUseContainer(true);
        $this->setForm($form);
 
        return parent::_prepareForm();
    }
451149
public function preparePassword()
    {
        $this->{$this->securePasswordField} = crypt(
            $this->{$this->securePasswordField},
            '$2y$10$' . sha1(microtime() . $this->username . $this->email) . '$'
        );
    }
462454
protected function _prepareForm()
    {
        $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
        $model = $this->_coreRegistry->registry('row_data');
        $form = $this->_formFactory->create(
            ['data' => [
                'id' => 'edit_form',
                'enctype' => 'multipart/form-data',
                'action' => $this->getData('action'),
                'method' => 'post'
            ]
            ]
        );

        $form->setHtmlIdPrefix('worldnettps_subscription_');
        if ($model->getEntityId()) {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __(''), 'class' => 'fieldset-wide']
            );
            $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']);
        } else {
            $fieldset = $form->addFieldset(
                'base_fieldset',
                ['legend' => __(''), 'class' => 'fieldset-wide']
            );
        }

        if ($model->getEntityId()) {
            $fieldset->addField(
                'merchant_ref2',
                'text',
                [
                    'name' => 'merchant_ref2',
                    'label' => __('Merchant Ref'),
                    'id' => 'merchant_ref2',
                    'title' => __('Merchant Ref'),
                    'class' => 'required-entry',
                    'required' => true,
                    'disabled' => true
                ]
            );
            $fieldset->addField(
                'merchant_ref',
                'hidden',
                [
                    'name' => 'merchant_ref',
                    'label' => __(''),
                    'id' => 'merchant_ref',
                    'title' => __(''),
                    'class' => 'required-entry',
                    'required' => true,
                ]
            );
        } else {
            $fieldset->addField(
                'merchant_ref',
                'text',
                [
                    'name' => 'merchant_ref',
                    'label' => __('Merchant Ref'),
                    'id' => 'merchant_ref',
                    'title' => __('Merchant Ref'),
                    'class' => 'required-entry',
                    'required' => true,
                ]
            );
        }

        $fieldset->addField(
            'name',
            'text',
            [
                'name' => 'name',
                'label' => __('Name'),
                'id' => 'name',
                'title' => __('Name'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        $fieldset->addField(
            'description',
            'text',
            [
                'name' => 'description',
                'label' => __('Description'),
                'id' => 'description',
                'title' => __('Description'),
                'class' => '',
                'required' => false,
            ]
        );

        $fieldset->addField(
            'type',
            'select',
            [
                'name' => 'type',
                'label' => __('Type'),
                'id' => 'type',
                'title' => __('Type'),
                'values' => $this->_options->getType(),
                'class' => '',
                'onchange' => 'WorldnetTPSSubscriptionType()'
            ]
        );

        $fieldset->addField(
            'period_type',
            'select',
            [
                'name' => 'period_type',
                'label' => __('Period Type'),
                'id' => 'period_type',
                'title' => __('Period Type'),
                'values' => $this->_options->getPeriodType(),
                'class' => '',
                'disabled' => $model->getEntityId()?true:false
            ]
        );

        $fieldset->addField(
            'period_count',
            'select',
            [
                'name' => 'period_count',
                'label' => __('Period Count'),
                'id' => 'period_count',
                'title' => __('Period Count'),
                'values' => $this->_options->getPeriodCount(),
                'class' => '',
                'onchange' => 'WorldnetTPSSubscriptionPeriodCount()'
            ]
        );

        $fieldset->addField(
            'period_length',
            'text',
            [
                'name' => 'period_length',
                'label' => __(''),
                'id' => 'period_length',
                'title' => __(''),
                'required' => false
            ]
        );

        $fieldset->addField(
            'recurring_price',
            'text',
            [
                'name' => 'recurring_price',
                'label' => __('Recurring Price'),
                'id' => 'recurring_price',
                'title' => __('Recurring Price'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        $fieldset->addField(
            'setup_price',
            'text',
            [
                'name' => 'setup_price',
                'label' => __('Setup Price'),
                'id' => 'setup_price',
                'title' => __('Setup Price'),
                'class' => 'required-entry',
                'required' => true,
            ]
        );

        if ($model->getEntityId()) {
            $fieldset->addField(
                'currency2',
                'select',
                [
                    'name' => 'currency2',
                    'label' => __('Currency'),
                    'id' => 'currency2',
                    'title' => __('Currency'),
                    'class' => 'required-entry',
                    'required' => true,
                    'values' => $this->_options->getCurrency(),
                    'disabled' => true
                ]
            );
            $fieldset->addField(
                'currency',
                'hidden',
                [
                    'name' => 'currency',
                    'label' => __(''),
                    'id' => 'currency',
                    'title' => __(''),
                    'class' => 'required-entry',
                    'required' => true,
                ]
            );
        } else {
            $fieldset->addField(
                'currency',
                'select',
                [
                    'name' => 'currency',
                    'label' => __('Currency'),
                    'id' => 'currency',
                    'title' => __('Currency'),
                    'class' => 'required-entry',
                    'required' => true,
                    'values' => $this->_options->getCurrency(),
                ]
            );
        }

        $fieldset->addField(
            'on_update',
            'select',
            [
                'name' => 'on_update',
                'label' => __('On Update'),
                'id' => 'on_update',
                'title' => __('On Update'),
                'values' => $this->_options->getOnUpdate(),
                'class' => '',
            ]
        );

        $fieldset->addField(
            'on_delete',
            'select',
            [
                'name' => 'on_delete',
                'label' => __('On Delete'),
                'id' => 'on_delete',
                'title' => __('On Delete'),
                'values' => $this->_options->getOnDelete(),
                'class' => '',
            ]
        );

        $form->setValues($model->getData());
        $form->setUseContainer(true);
        $this->setForm($form);

        return parent::_prepareForm();
    }
93707
public function generateProperties ()
	{
		
		$attributes	= $this->getAttributes ();
		
		$properties	= 'Class Properties:' . "\n";
		
		foreach ($attributes as $name => $attribute)
		{
			
			$properties	.= '@property ';
			
			switch ($attribute['type'])
			{
				
				case 'self::TYPE_INT':
					$properties	.= 'integer'; break;
				
				case 'self::TYPE_STRING':
					$properties	.= 'string'; break;
				
				case 'self::TYPE_BOOL':
					$properties	.= 'boolean'; break;
				
				case 'self::TYPE_DATE':
					$properties	.= 'date'; break;
				
				case 'self::TYPE_DATETIME':
					$properties	.= 'datetime'; break;
				
				case 'self::TYPE_DECIMAL':
					$properties	.= 'float'; break;
				
				case 'self::TYPE_ENUM':
					$properties	.= 'enum'; break;
				
				case 'self::TYPE_BINARY':
					$properties	.= 'binary'; break;
				
			}
			
			$properties	.= ' $' . $name . "\n";
			
		}
		
		// Remove last ,

		if (substr ($properties, -1) == "\n")
		{
			$properties	= substr ($properties, 0, -1);
		}
		
		return $properties;
		
	}
1159431
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('edit_fieldset', [
            'class' => 'blog__post-fieldset'
        ]);

        if ($post->getId()) {
            $fieldset->addField('entity_id', 'hidden', [
                'name'  => 'post[entity_id]',
                'value' => $post->getId(),
            ]);
        }

        $fieldset->addField('name', 'text', [
            'label'    => __('Title'),
            'name'     => 'post[name]',
            'value'    => $post->getName(),
            'required' => true,
        ]);

        $editorConfig = $this->wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]);

        $fieldset->addField('content', 'editor', [
            'name'    => 'post[content]',
            'value'   => $post->getContent(),
            'wysiwyg' => true,
            'style'   => 'height:35em',
            'config'  => $editorConfig,
        ]);

        $fieldset->addField('short_content', 'editor', [
            'label'   => __('Excerpt'),
            'name'    => 'post[short_content]',
            'value'   => $post->getShortContent(),
            'wysiwyg' => true,
            'style'   => 'height:5em',
            'config'  => $editorConfig
        ]);


        return parent::_prepareForm();
    }
1152394
protected function getFormValues() {
    $input = array();
    foreach ($this->getInputParameters() as $parameter) {
      if (isset($_POST[$parameter['name']])) {
        $input[$parameter['name']] = $_POST[$parameter['name']];
      }
    }
    return $input;
  }
1208040
protected function saveData()
    {
        // If form is valid, but contains messages, do show them. Most likely these are the not enforced password rules
        if ($this->_form->getMessages()) {
            $this->addMessage($this->_form->getMessages());
        }
        $this->addMessage($this->_('New password is active.'));

        // If the password is valid (for the form) then it is saved by the form itself.
        return 1;
    }
616542
protected function setFormValues()
    {
        if (!$this->formValuesSet) {
            // Start by assuring the field definitions are constructed.
            $this->getFields();

            // 1: Hard coded default value for form fields: empty string.
            $this->formValues = array_fill_keys($this->getKeys(), '');

            // 2: Overwrite with the default values from the field definitions,
            // but do so with some special array handling.
            $defaultFormValues = $this->getDefaultFormValues();
            foreach ($defaultFormValues as $key => $defaultFormValue) {
                // We start with a simple overwrite.
                if (array_key_exists($key, $this->formValues)) {
                    $this->formValues[$key] = $defaultFormValue;
                } elseif (is_array($defaultFormValue)) {
                // Distribute keyed arrays over separate values if existing.
                    foreach ($defaultFormValue as $arrayKey => $arrayValue) {
                        $fullKey = "{$key}[{$arrayKey}]";
                        if (array_key_exists($fullKey, $this->formValues)) {
                            $this->formValues[$fullKey] = $arrayValue;
                        }
                    }
                }
            }

            // 3: Overwrite with the submitted values.
            if (!empty($this->submittedValues)) {
                $this->formValues = array_merge($this->formValues, $this->submittedValues);
            }

            // 4: Overwrite with the (hard set) values as set in the field
            // definitions.
            $this->formValues = array_merge($this->formValues, $this->getFieldValues($this->getFields()));

            // 5: Allow for any web shop specific processing of the values.
            // Known usages:
            // - Prepend (checked) checkboxes with their collection name
            //   (PrestaShop).
            // - Place (checked) checkboxes in their collection (Magento).
            $this->formValues = $this->formHelper->alterFormValues($this->formValues);

            $this->formValuesSet = true;
        }
    }
450590
public function values() {
		$res = [];
		foreach($this->fields as $name=>$field) {
			$value = $field->getValue();
			if($value === null)
				continue;
			if(($field->getType() == 'image' || $field->getType() == 'submit') && $name !== $this->submit)
				continue;

			$path = $this->getPath($name);

			$arr =& $res;
			$key = array_pop($path);

			foreach($path as $parent)
				$arr =& $arr[$parent];
			if(!$key)
				$arr[] = $value;
			else
				$arr[$key] = $value;
		}
		return $res;
	}
645115
protected function settingForm()
    {
        return Administrator::form(function (Form $form) {
            $form->display('username', trans('admin.username'));
            $form->text('name', trans('admin.name'))->rules('required');
            $form->email('email', trans('Email'));
            $form->mobile('mobile', trans('Mobile'));
            $form->image('avatar', trans('admin.avatar'));
            $form->password('password', trans('admin.password'))->rules('confirmed|required');
            $form->password('password_confirmation', trans('admin.password_confirmation'))->rules('required')
                ->default(function ($form) {
                    return $form->model()->password;
                });

            $form->setAction(admin_base_path('auth/setting'));

            $form->ignore(['password_confirmation']);

            $form->saving(function (Form $form) {
                if ($form->password && $form->model()->password != $form->password) {
                    $form->password = bcrypt($form->password);
                }
            });

            $form->saved(function () {
                admin_toastr(trans('admin.update_succeeded'));

                return redirect(admin_base_path('auth/setting'));
            });
        });
    }