Example #1
1
 public function run()
 {
     // Create a View (radio)
     /*$view['radio'] = Viewr::create(array(
                 'path'              => 'public.form.input.radio',
             ));
     
             $view['textarea'] = Viewr::create(array(
                 'path'              => 'public.form.input.textarea',
             ));
     
             $view['text'] = Viewr::create(array(
                 'path'              => 'public.form.input.text',
             ));
     
             $view['password'] = Viewr::create(array(
                 'path'              => 'public.form.input.password',
             ));
     
             $view['hidden'] = Viewr::create(array(
                 'path'              => 'public.form.input.hidden',
             ));        
     
             $view['checkbox'] = Viewr::create(array(
                 'path'              => 'public.form.input.checkbox',
             ));     
     
             $view['submit'] = Viewr::create(array(
                 'path'              => 'public.form.input.submit',
             ));  
     
             $view['select'] = Viewr::create(array(
                 'path'              => 'public.form.input.select',
             ));           
     
             $this->command->info('View created => next step');*/
     /**
      * 
      * Title translation
      * 
      */
     // i18n radio title
     $i18n['title']['radio'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : radio title
     $translation['title']['radio']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['radio']->id, 'locale_id' => 'fr', 'text' => 'Titre du radion'));
     // Translation EN : radio title
     $translation['title']['radio']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['radio']->id, 'locale_id' => 'en', 'text' => 'Radio title'));
     // i18n textarea title
     $i18n['title']['textarea'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : textarea title
     $translation['title']['textarea']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['textarea']->id, 'locale_id' => 'fr', 'text' => 'Titre du Textarea'));
     // Translation EN : textarea title
     $translation['title']['textarea']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['textarea']->id, 'locale_id' => 'en', 'text' => 'Textarea title'));
     // i18n text title
     $i18n['title']['text'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : text title
     $translation['title']['text']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['text']->id, 'locale_id' => 'fr', 'text' => 'Titre du text'));
     // Translation EN : text title
     $translation['title']['text']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['text']->id, 'locale_id' => 'en', 'text' => 'Text title'));
     // i18n password title
     $i18n['title']['password'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : password title
     $translation['title']['password']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['password']->id, 'locale_id' => 'fr', 'text' => 'Titre du password'));
     // Translation EN : password title
     $translation['title']['password']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['password']->id, 'locale_id' => 'en', 'text' => 'PAssword title'));
     // i18n hidden title
     $i18n['title']['hidden'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : hidden title
     $translation['title']['hidden']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['hidden']->id, 'locale_id' => 'fr', 'text' => 'Titre du hidden'));
     // Translation EN : hidden title
     $translation['title']['hidden']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['hidden']->id, 'locale_id' => 'en', 'text' => 'hidden title'));
     // i18n checkbox title
     $i18n['title']['checkbox'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : checkbox title
     $translation['title']['checkbox']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['checkbox']->id, 'locale_id' => 'fr', 'text' => 'Titre du checkbox'));
     // Translation EN : checkbox title
     $translation['title']['checkbox']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['checkbox']->id, 'locale_id' => 'en', 'text' => 'checkbox title'));
     // i18n submit title
     $i18n['title']['submit'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : submit title
     $translation['title']['submit']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['submit']->id, 'locale_id' => 'fr', 'text' => 'Titre du submit'));
     // Translation EN : submit title
     $translation['title']['submit']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['submit']->id, 'locale_id' => 'en', 'text' => 'submit title'));
     // i18n select title
     $i18n['title']['select'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : select title
     $translation['title']['select']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['select']->id, 'locale_id' => 'fr', 'text' => 'Titre du select'));
     // Translation EN : select title
     $translation['title']['select']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['select']->id, 'locale_id' => 'en', 'text' => 'select title'));
     /**
      *
      * label translation
      * 
      */
     // i18n radio label
     $i18n['label']['radio'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : radio label
     $translation['label']['radio']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['radio']->id, 'locale_id' => 'fr', 'text' => 'Titre du radion'));
     // Translation EN : radio label
     $translation['label']['radio']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['radio']->id, 'locale_id' => 'en', 'text' => 'Radio label'));
     // i18n textarea label
     $i18n['label']['textarea'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : textarea label
     $translation['label']['textarea']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['textarea']->id, 'locale_id' => 'fr', 'text' => 'Titre du Textarea'));
     // Translation EN : textarea label
     $translation['label']['textarea']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['textarea']->id, 'locale_id' => 'en', 'text' => 'Textarea label'));
     // i18n text label
     $i18n['label']['text'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : text label
     $translation['label']['text']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['text']->id, 'locale_id' => 'fr', 'text' => 'Titre du text'));
     // Translation EN : text label
     $translation['label']['text']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['text']->id, 'locale_id' => 'en', 'text' => 'Text label'));
     // i18n password label
     $i18n['label']['password'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : password label
     $translation['label']['password']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['password']->id, 'locale_id' => 'fr', 'text' => 'Titre du password'));
     // Translation EN : password label
     $translation['label']['password']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['password']->id, 'locale_id' => 'en', 'text' => 'PAssword label'));
     // i18n hidden label
     $i18n['label']['hidden'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : hidden label
     $translation['label']['hidden']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['hidden']->id, 'locale_id' => 'fr', 'text' => 'Titre du hidden'));
     // Translation EN : hidden label
     $translation['label']['hidden']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['hidden']->id, 'locale_id' => 'en', 'text' => 'hidden label'));
     // i18n checkbox label
     $i18n['label']['checkbox'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : checkbox label
     $translation['label']['checkbox']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['checkbox']->id, 'locale_id' => 'fr', 'text' => 'Titre du checkbox'));
     // Translation EN : checkbox label
     $translation['label']['checkbox']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['checkbox']->id, 'locale_id' => 'en', 'text' => 'checkbox label'));
     // i18n submit label
     $i18n['label']['submit'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : submit label
     $translation['label']['submit']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['submit']->id, 'locale_id' => 'fr', 'text' => 'Titre du submit'));
     // Translation EN : submit label
     $translation['label']['submit']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['submit']->id, 'locale_id' => 'en', 'text' => 'submit label'));
     // i18n select label
     $i18n['label']['select'] = I18n::create(array('i18n_type_id' => 2));
     // Translation FR : select label
     $translation['label']['select']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['select']->id, 'locale_id' => 'fr', 'text' => 'Titre du select'));
     // Translation EN : select label
     $translation['label']['select']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['select']->id, 'locale_id' => 'en', 'text' => 'select label'));
     // Input types
     $InputType['radio'] = InputType::create(array('name' => 'maradio', 'rules' => 'required', 'i18n_title' => $i18n['title']['radio']->id));
     $InputType['textarea'] = InputType::create(array('name' => 'monTextarea', 'rules' => 'required', 'i18n_title' => $i18n['title']['textarea']->id));
     $InputType['text'] = InputType::create(array('name' => 'blabla', 'rules' => 'required', 'i18n_title' => $i18n['title']['text']->id));
     $InputType['password'] = InputType::create(array('name' => 'passwd', 'rules' => 'required', 'i18n_title' => $i18n['title']['password']->id));
     $InputType['hidden'] = InputType::create(array('name' => 'testhidden', 'rules' => 'required', 'defaultValue' => 'Je suis une valeur requise', 'i18n_title' => $i18n['title']['hidden']->id));
     $InputType['checkbox'] = InputType::create(array('name' => 'test', 'rules' => 'required', 'i18n_title' => $i18n['title']['checkbox']->id));
     $InputType['submit'] = InputType::create(array('name' => 'submit', 'rules' => 'required', 'i18n_title' => $i18n['title']['submit']->id));
     $InputType['select'] = InputType::create(array('name' => 'aselect', 'rules' => 'required', 'i18n_title' => $i18n['title']['select']->id));
     $this->command->info('Input types created => next step');
     // i18n : Placeholder 1
     $i18n['placeholder'][1] = I18n::create(array('i18n_type_id' => 9));
     // i18n : Helper 1
     $i18n['helper'][1] = I18n::create(array('i18n_type_id' => 10));
     // i18n form title
     $i18n['title'] = I18n::create(array('i18n_type_id' => 2));
     // i18n form description
     $i18n['description'] = I18n::create(array('i18n_type_id' => 4));
     // Translation FR : Placeholder 1
     $translation['placeholder']['FR'][1] = Translation::create(array('i18n_id' => $i18n['placeholder'][1]->id, 'locale_id' => 'fr', 'text' => 'Complete moi stp'));
     // Translation EN : Placeholder 1
     $translation['placeholder']['EN'][1] = Translation::create(array('i18n_id' => $i18n['placeholder'][1]->id, 'locale_id' => 'en', 'text' => 'Please complete me'));
     // Translation FR : Helper 1
     $translation['helper']['FR'][1] = Translation::create(array('i18n_id' => $i18n['helper'][1]->id, 'locale_id' => 'fr', 'text' => 'Un impressionnant helper !'));
     // Translation EN : Helper 1
     $translation['helper']['EN'][1] = Translation::create(array('i18n_id' => $i18n['helper'][1]->id, 'locale_id' => 'en', 'text' => 'An awesome helper !'));
     // Translation FR : Form title
     $translation['title']['FR'] = Translation::create(array('i18n_id' => $i18n['title']->id, 'locale_id' => 'fr', 'text' => 'My awesome form'));
     // Translation EN : Form title
     $translation['title']['EN'] = Translation::create(array('i18n_id' => $i18n['title']->id, 'locale_id' => 'en', 'text' => 'My awesome form'));
     // Translation FR : Form description
     $translation['description']['FR'] = Translation::create(array('i18n_id' => $i18n['description']->id, 'locale_id' => 'fr', 'text' => 'Description of a form'));
     // Translation EN : Form description
     $translation['description']['EN'] = Translation::create(array('i18n_id' => $i18n['description']->id, 'locale_id' => 'en', 'text' => 'Description of a form'));
     $this->command->info('Translations created => next step');
     // Inputs
     $input[1] = InputView::create(array('name' => "radio", 'view_id' => 1, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['radio']->id, 'type_id' => $InputType['radio']->id));
     $input[2] = InputView::create(array('name' => "textarea", 'view_id' => 2, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['textarea']->id, 'type_id' => $InputType['textarea']->id));
     $input[3] = InputView::create(array('name' => "text", 'view_id' => 3, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['text']->id, 'type_id' => $InputType['text']->id));
     $input[4] = InputView::create(array('name' => "password", 'view_id' => 4, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['password']->id, 'type_id' => $InputType['password']->id));
     $input[5] = InputView::create(array('name' => "hidden", 'view_id' => 5, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['hidden']->id, 'type_id' => $InputType['hidden']->id));
     $input[6] = InputView::create(array('name' => "checkbox", 'view_id' => 6, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['checkbox']->id, 'type_id' => $InputType['checkbox']->id));
     $input[7] = InputView::create(array('name' => "submit", 'view_id' => 7, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['submit']->id, 'type_id' => $InputType['submit']->id));
     $input[8] = InputView::create(array('name' => "select", 'view_id' => 8, 'i18n_placeholder' => $i18n['placeholder'][1]->id, 'i18n_helper' => $i18n['helper'][1]->id, 'i18n_label' => $i18n['label']['select']->id, 'type_id' => $InputType['select']->id));
     $this->command->info('Inputs created => next step');
     // Form
     $form = Formr::create(array('finish_on' => 'model', 'type' => 'horizontal', 'i18n_title' => $i18n['title']->id, 'i18n_description' => $i18n['description']->id));
     $this->command->info('Form created => next step');
     // For maps
     $formMap[1] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[1]->id, 'order' => 1));
     $formMap[2] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[2]->id, 'order' => 2));
     $formMap[3] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[3]->id, 'order' => 3));
     $formMap[4] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[4]->id, 'order' => 4));
     $formMap[5] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[5]->id, 'order' => 5));
     $formMap[8] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[8]->id, 'order' => 6));
     $formMap[7] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[7]->id, 'order' => 7));
     $formMap[6] = FormMap::create(array('form_id' => $form->id, 'input_id' => $input[6]->id, 'order' => 8));
     // Text for options
     // Option 1
     $option18n[1]['key'] = I18n::create(array('i18n_type_id' => 6));
     $option18n[1]['value'] = I18n::create(array('i18n_type_id' => 6));
     // Option 2
     $option18n[2]['key'] = I18n::create(array('i18n_type_id' => 6));
     $option18n[2]['value'] = I18n::create(array('i18n_type_id' => 6));
     // Option 3
     $option18n[3]['key'] = I18n::create(array('i18n_type_id' => 6));
     $option18n[3]['value'] = I18n::create(array('i18n_type_id' => 6));
     // OPTION 1
     // Translation FR : option 1
     Translation::create(array('i18n_id' => $option18n[1]['key']->id, 'locale_id' => 'fr', 'text' => 'mon option 1'));
     // Translation EN : option 1
     Translation::create(array('i18n_id' => $option18n[1]['key']->id, 'locale_id' => 'en', 'text' => 'my option 1'));
     // Translation FR : option 1
     Translation::create(array('i18n_id' => $option18n[1]['value']->id, 'locale_id' => 'fr', 'text' => 'valeur ici 1'));
     // Translation EN : option 1
     Translation::create(array('i18n_id' => $option18n[1]['value']->id, 'locale_id' => 'en', 'text' => 'value here 1'));
     // OPTION 2
     // Translation FR : option 2
     Translation::create(array('i18n_id' => $option18n[2]['key']->id, 'locale_id' => 'fr', 'text' => 'Test de mon option 2'));
     // Translation EN : option 2
     Translation::create(array('i18n_id' => $option18n[2]['key']->id, 'locale_id' => 'en', 'text' => 'Test of my option 2'));
     // Translation FR : option 2
     Translation::create(array('i18n_id' => $option18n[2]['value']->id, 'locale_id' => 'fr', 'text' => 'valeur ici 2'));
     // Translation EN : option 2
     Translation::create(array('i18n_id' => $option18n[2]['value']->id, 'locale_id' => 'en', 'text' => 'value here 2'));
     // OPTION 3
     // Translation FR : option 3
     Translation::create(array('i18n_id' => $option18n[3]['key']->id, 'locale_id' => 'fr', 'text' => '3eme option'));
     // Translation EN : option 3
     Translation::create(array('i18n_id' => $option18n[3]['key']->id, 'locale_id' => 'en', 'text' => '3rd option'));
     // Translation FR : option 3
     Translation::create(array('i18n_id' => $option18n[3]['value']->id, 'locale_id' => 'fr', 'text' => 'valeur ici 3'));
     // Translation EN : option 3
     Translation::create(array('i18n_id' => $option18n[3]['value']->id, 'locale_id' => 'en', 'text' => 'value here 3'));
     // Options of select
     SelectOption::create(array('input_id' => $input[8]->id, 'i18n_key' => $option18n[1]['key']->id, 'i18n_value' => $option18n[1]['value']->id));
     SelectOption::create(array('input_id' => $input[8]->id, 'i18n_key' => $option18n[2]['key']->id, 'i18n_value' => $option18n[2]['value']->id));
     SelectOption::create(array('input_id' => $input[8]->id, 'i18n_key' => $option18n[3]['key']->id, 'i18n_value' => $option18n[3]['value']->id));
     $this->command->info('Form maps created');
     ModelForm::create(array('form_id' => $form->id, 'model' => 'gallery'));
     $this->command->info('Models form created');
 }
Example #2
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new ModelForm();
     if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) {
         $form->save();
         $this->redirectBack();
     }
     $this->forms['Model'] = $form;
 }
 public function __construct($controllerId, $moduleId, ModelForm $searchModel, RedBeanModel $listModel, $moduleName, CDataProvider $dataProvider, $selectedIds)
 {
     parent::__construct(3, 1);
     $moduleClassName = $moduleName . 'Module';
     $titleBarView = new TitleBarView($moduleClassName::getModuleLabelByTypeAndLanguage('Plural'), Zurmo::t('ZurmoModule', 'Home'), 1);
     $this->setView($titleBarView, 0, 0);
     $searchViewClassName = $moduleName . 'SearchView';
     $this->setView(new $searchViewClassName($searchModel, get_class($listModel)), 1, 0);
     $listViewClassName = $moduleName . 'ListView';
     $this->setView(new $listViewClassName($controllerId, $moduleId, get_class($listModel), $dataProvider, $selectedIds, null, array(), $searchModel->getListAttributesSelector()), 2, 0);
 }
 public function __construct($controllerId, $moduleId, ModelForm $searchModel, RedBeanModel $listModel, $moduleName, CDataProvider $dataProvider, $selectedIds, $actionBarViewClassName)
 {
     assert('is_string($controllerId)');
     assert('is_string($moduleId)');
     assert('is_string($actionBarViewClassName)');
     parent::__construct(3, 1);
     $searchViewClassName = $moduleName . 'SearchView';
     $searchView = new $searchViewClassName($searchModel, get_class($listModel));
     $listViewClassName = $moduleName . 'ListView';
     $listView = new $listViewClassName($controllerId, $moduleId, get_class($listModel), $dataProvider, $selectedIds, null, array(), $searchModel->getListAttributesSelector());
     $actionBarView = new $actionBarViewClassName($controllerId, $moduleId, $listModel, $listView->getGridViewId(), $dataProvider->getPagination()->pageVar, $listView->getRowsAreSelectable());
     $this->setView($actionBarView, 0, 0);
     $this->setView($searchView, 1, 0);
     $this->setView($listView, 2, 0);
 }
 public function isAttributeRequired($attribute)
 {
     if ($this->isCustomRequiredAttribute($attribute)) {
         return true;
     }
     return parent::isAttributeRequired($attribute);
 }
 public function afterValidate()
 {
     parent::afterValidate();
     if ($this->getScenario() === 'createUser' || $this->getScenario() === 'changePassword') {
         $this->model->setPassword((string) $this->newPassword);
     }
 }
 /**
  * Save the emailSignatureHtmlContent
  */
 public function save($runValidation = true, array $attributeNames = null)
 {
     if (parent::save(false)) {
         $emailSignature = $this->model->user->getEmailSignature();
         $emailSignature->htmlContent = $this->emailSignatureHtmlContent;
         $this->model->user->save();
     } else {
         return false;
     }
     return true;
 }
 /**
  * Returns the element or attribute form type
  * that should be used with the named attribute
  * of the given model, (the name minus the Element
  * or AttributeForm suffix).
  */
 public static function getDesignerType(ModelForm $model, $attributeName)
 {
     assert('$model !== null');
     assert('is_string($attributeName) && $attributeName != ""');
     $metadata = $model->getMetadata();
     foreach ($metadata as $className => $perClassMetadata) {
         if (isset($perClassMetadata['elements'][$attributeName])) {
             return $perClassMetadata['elements'][$attributeName];
         }
     }
     $validators = $model->getValidators($attributeName);
     foreach ($validators as $validator) {
         switch (get_class($validator)) {
             case 'CBooleanValidator':
                 return 'CheckBox';
             case 'CEmailValidator':
                 return 'Email';
             case 'RedBeanModelTypeValidator':
             case 'TypeValidator':
                 switch ($validator->type) {
                     case 'date':
                         return 'Date';
                     case 'datetime':
                         return 'DateTime';
                     case 'integer':
                         return 'Integer';
                     case 'float':
                         return 'Decimal';
                     case 'time':
                         return 'Time';
                     case 'array':
                         throw new NotSupportedException();
                 }
                 break;
             case 'CUrlValidator':
                 return 'Url';
         }
     }
     return 'Text';
 }
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package    mod_customlabel
 * @author     Valery Fremaux <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 1999 onwards Martin Dougiamas  http://dougiamas.com
 *
 */
require_once $CFG->dirroot . '/mod/customlabel/forms/ClassificationModelForm.php';
$mform = new ModelForm();
if (!$mform->is_cancelled()) {
    if ($data = $mform->get_data()) {
        set_config('classification_type_table', $data->classification_type_table);
        set_config('classification_value_table', $data->classification_value_table);
        set_config('classification_value_type_key', $data->classification_value_type_key);
        set_config('classification_constraint_table', $data->classification_constraint_table);
        set_config('course_metadata_table', $data->course_metadata_table);
        set_config('course_metadata_value_key', $data->course_metadata_value_key);
        set_config('course_metadata_course_key', $data->course_metadata_course_key);
    }
}
// Print table.
echo $deferredheader;
echo $OUTPUT->heading(get_string('classificationmodel', 'customlabel'));
$data = new StdClass();
 public function afterValidate()
 {
     parent::afterValidate();
     $this->model->serializeAndSetAvatarData(array('avatarType' => $this->avatarType, 'customAvatarEmailAddress' => $this->customAvatarEmailAddress));
 }
Example #11
0
 public function generate($data, $pageId, $order)
 {
     $form = new self();
     $fromObject = false;
     if (is_object($data)) {
         $data = $data->formr();
         $form->i18n_title = NULL;
         $form->i18n_description = NULL;
         $fromObject = true;
     }
     $form->finish_on = $data['method'];
     $form->type = $data['type'];
     $form->save();
     $orderMap = 0;
     foreach ($data['data'] as $dataInput) {
         // Increments the order
         $orderMap++;
         if ($fromObject) {
             $dataInput['title'] = NULL;
             $dataInput['label'] = NULL;
             $dataInput['placeholder'] = NULL;
             $dataInput['helper'] = NULL;
         } else {
             $dataInput['title'] = i18n::add($dataInput['title'], 'title');
             $dataInput['label'] = i18n::add($dataInput['label'], 'label');
             $dataInput['placeholder'] = i18n::add($dataInput['placeholder'], 'placeholder');
             $dataInput['helper'] = i18n::add($dataInput['helper'], 'helper');
         }
         $inputType = InputType::add($dataInput);
         $input = InputView::add($inputType->id, $dataInput);
         // Add options if the input type is a select
         if ($input->name = "select") {
             if (isset($dataInput['options'])) {
                 foreach ($dataInput['options'] as $option) {
                     if ($fromObject) {
                         $option['key'] = NULL;
                         $option['value'] = NULL;
                     } else {
                         $option['key'] = i18n::add($option['key'], 'option_key');
                         $option['value'] = i18n::add($option['value'], 'option_value');
                     }
                     SelectOption::add($input->id, $option);
                 }
             }
         }
         // Add form map
         FormMap::add($input->id, $form->id, $orderMap);
     }
     // Add a block if the form is not by a model
     if (!$fromObject) {
         $block = Block::add($pageId, $order, 'Formr');
         BlockResponsive::add($block->id, 12, 3);
     }
     if ($fromObject) {
         // Add form model
         ModelForm::add($form->id, $data['model']);
     }
     // Generate a migrate file
     if ($form->finish_on == "database") {
         // Prepare migrate content
         $contentMigrate = $this->prepareMigrate($data['data']);
         $bob = new Migrator('form_' . $form->id, $contentMigrate);
         $bob->generate();
     }
     return $form;
 }
Example #12
0
 /**
  * (non-PHPdoc)
  * @see ModelForm::setAttributes()
  */
 public function setAttributes($values, $safeOnly = true)
 {
     $nonDyanmicAttributeValues = array();
     foreach ($values as $name => $value) {
         if ($this->doesNameResolveNameForDelimiterSplit($name)) {
             $this->{$name} = $value;
         } else {
             $nonDyanmicAttributeValues[$name] = $value;
         }
     }
     //Dropdowns can be searched on as mulit-selects.  This below foreach resolves the issue of needing to show
     //multiple values in the dropdown.
     foreach ($values as $name => $value) {
         if ($value != null && $this->model->isAttribute($name) && $this->model->isRelation($name)) {
             $relationModelClassName = $this->model->getRelationModelClassName($name);
             if ($relationModelClassName == 'CustomField' || is_subclass_of($relationModelClassName, 'CustomField') && isset($value['value']) && is_array($value['value']) && count($value['value']) > 0) {
                 $this->model->{$name}->value = $value['value'];
             }
         }
     }
     parent::setAttributes($nonDyanmicAttributeValues, $safeOnly);
 }
Example #13
0
 function PrintEditForm($id)
 {
     if ($data = $this->implementation->Read($id)) {
         $action = $this::$name . '/' . $id;
         $model = $this->PrepareModel();
         $form = new ModelForm($model, "edit-form", $action, "PUT", $this::$name);
         $form->import_object($data);
         $form->render();
     } else {
         echo "<div class=\"listtitle\"><span>Error - invalid id provided</span></div>";
     }
 }
Example #14
0
File: Form.php Project: ricobl/frix
	function render () {
		
		// Extra data will be used to render multiple lines
		// If not set, create a single line
		if (!$this->extra) {
			$this->extra = sprintf('<tr>%s</tr>', $this->render_fields());
		}
		
		return parent::render();
		
	}
Example #15
0
 /**
  * Override to handle userStatus validation
  * @param User | ModelForm $model
  * @param string $postVariableName
  */
 protected function attemptToValidateAjaxFromPost($model, $postVariableName)
 {
     if (isset($_POST['ajax']) && $_POST['ajax'] == 'edit-form') {
         $model->setAttributes($_POST[$postVariableName]);
         $model->validate();
         $userStatus = UserStatusUtil::makeByPostData($_POST[$postVariableName]);
         if ($model instanceof User) {
             if ($userStatus == null) {
                 $userStatus = UserStatusUtil::makeByUser($model);
             }
             Yii::app()->licenseManager->resolveValidationOnCreateOrEditUser($model, $userStatus);
         } elseif ($model instanceof ModelForm) {
             if ($userStatus == null) {
                 $userStatus = UserStatusUtil::makeByUser($model->getModel());
             }
             Yii::app()->licenseManager->resolveValidationOnCreateOrEditUser($model->getModel(), $userStatus);
         }
         $errorData = ZurmoActiveForm::makeErrorsDataAndResolveForOwnedModelAttributes($model);
         echo CJSON::encode($errorData);
         Yii::app()->end(0, false);
     }
 }
Example #16
0
    function editVideoPage()
    {
        $tp = $this->task_parts;
        $data = $this->implementation->Read($tp[1]);
        $model = $this->PrepareModel();
        //$model['title'] = 'Cheese';
        $action = 'video/' . $tp[1];
        $form = new ModelForm($model, "add_form", $action, "PUT", 'video', "loadVideoPreview('" . $data->{'_id'} . "');");
        $form->import_object($data);
        ?>
<div class="row">
    
    <div class="small-12 medium-12 large-8 column">
        <?php 
        $form->render();
        ?>
    </div>
   
    
     <div class="small-12 medium-12 large-4 column video-info" id="video-preview-section">
        <div class="video-preview-parent">
            <div class="video-preview-container">
                <div class="video-preview"></div>
            </div>
        </div>
        <div class="video-info-text">
        </div>
        <div class="video-info-actions theme-color"></div>
    </div>
    
    <script>
        loadVideoPreview('<?php 
        echo $data->{'_id'};
        ?>
');
    </script>
    
</div>
<?php 
    }