/** * Fields config for backend. * * @access public * @return ModelCore\MConfig * @since 1.0.0-alpha * @version 1.0.0-alpha */ protected static function generateConfig() { $oConfig = parent::generateConfig(); $currentRouteName = Router::getCurrentRouteName(); $currentRouteParams = Router::getParams(); $oConfig->addField(Form\Field\Hidden::singleton('id')->setLabel(__('ID'))->setDisabled()); // BACKEND if ($currentRouteName === 'backend' && in_array($currentRouteParams['action'], ['edit', 'list'])) { $oConfig->addField(Form\Field\Text::singleton('name')->setLabel(__('File name'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('ext')->setLabel(__('File extension'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('file_path')->setLabel(__('File path'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('mime')->setLabel(__('File MIME type'))->setDisabled()); $oConfig->addField(Form\Field\Text::singleton('size')->setLabel(__('File size'))->setTip(__('File size in KB.'))->setDisabled()); $oConfig->addField(Form\Field\Select::singleton('status')->setOptions([0 => __('Temporary'), 1 => __('Permanent')])->setLabel(__('Status'))->setDisabled()); } return $oConfig; }
/** * Set value for database field from form. * * @author Krzysztof Trzos * @access protected * @param string $sName * @param mixed $mValue * @param Form\Field $oFormField * @return boolean * @since 1.0.1-dev, 2015-02-20 * @version 2.1.1-dev */ protected function makeDataTransfer($sName, $mValue, Form\Field &$oFormField) { $sCurrentRoute = Router::getCurrentRouteName(); $aCurrentRouteParams = Router::getParams(); switch ($sName) { case 'password': switch ($sCurrentRoute) { case 'backend': if ($aCurrentRouteParams['controller'] === 'user' && $aCurrentRouteParams['action'] === 'edit') { if (empty($mValue['und'][0])) { return FALSE; } } break; } break; } return parent::makeDataTransfer($sName, $mValue, $oFormField); }