Example #1
0
 /**
  * Formr action
  * @param  Array $inputs
  */
 public static function formAction($dataInput)
 {
     //return var_dump($dataInput);
     if (!isset($dataInput['formParam']) || !isset($dataInput['formParam']['formId'])) {
         App::abbort(404);
     }
     $form = Formr::findOrFail($dataInput['formParam']['formId']);
     // recuperation de l'ordre pour le nouvel input
     $lastOrder = self::mapping($form);
     // Suppression du dernier pipe et surchage de "data['rules']"
     $dataInput['rules'] = isset($dataInput['rules']) ? self::generateRules($dataInput['rules']) : "";
     $view = Viewr::where('name', $dataInput['type'])->firstOrFail();
     $dataInput['view'] = $view->id;
     $dataInput = array_merge($dataInput, self::generateI18n($dataInput));
     $inputType = InputType::add($dataInput);
     $input = self::add($inputType->id, $dataInput);
     /**
      *
      *
      *
      *
      *
      *  A  FAIRE : TRAITER LES OPTIONS
      *
      *
      *
      *
      *
      * 
      */
     // Add options if the input type is a select
     if ($input->name = "select") {
         if (isset($dataInput['options'])) {
             foreach ($dataInput['options'] as $option) {
                 $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, $lastOrder);
     return Redirect::route('admin.form.show', $form->id);
 }
Example #2
0
 public function run()
 {
     DB::table('views')->delete();
     /*DB::table('views')->insert( array(
           array(
               'path'       => 'public.pages.content',
               'created_at' => new DateTime,
               'updated_at' => new DateTime
           ))
       );*/
     $view['radio'] = Viewr::create(array('name' => 'radio', 'path' => 'public.form.input.radio'));
     $view['textarea'] = Viewr::create(array('name' => 'textarea', 'path' => 'public.form.input.textarea'));
     $view['text'] = Viewr::create(array('name' => 'text', 'path' => 'public.form.input.text'));
     $view['password'] = Viewr::create(array('name' => 'password', 'path' => 'public.form.input.password'));
     $view['hidden'] = Viewr::create(array('name' => 'hidden', 'path' => 'public.form.input.hidden'));
     $view['checkbox'] = Viewr::create(array('name' => 'checkbox', 'path' => 'public.form.input.checkbox'));
     $view['submit'] = Viewr::create(array('name' => 'submit', 'path' => 'public.form.input.submit'));
     $view['select'] = Viewr::create(array('name' => 'select', 'path' => 'public.form.input.select'));
     $view['multiselect'] = Viewr::create(array('name' => 'multiselect', 'path' => 'public.form.input.multiselect'));
     $view['filemanager'] = Viewr::create(array('name' => 'filemanager', 'path' => 'public.form.input.filemanager'));
 }