Exemple #1
0
 public function pre_render_html($form)
 {
     $hidden_field = Ffield::factory('_formo', 'hidden', array('value' => $form->alias()));
     // A a special hidden fielm just to the HTML form
     $form->prepend($hidden_field);
     $form->set('tag', 'form')->attr('method', $this->get('method', 'post'))->attr('action', $this->get('action', ''));
 }
Exemple #2
0
 public function pre_render_html($field)
 {
     foreach ($field->options as $label => $options) {
         $options = is_array($options) ? $options : array('value' => $options);
         $checkbox = Ffield::factory($label, 'checkbox', $options);
         $field->append($checkbox);
     }
 }
Exemple #3
0
 public function pre_render_html($field)
 {
     $field->append(Ffield::factory('', 'option'));
     foreach ($field->options as $label => $options) {
         $options = is_array($options) ? $options : array('value' => $options);
         $checkbox = Ffield::factory($label, 'option', $options);
         $field->append($checkbox);
     }
     $field->set('tag', 'select')->attr('name', $field->alias());
 }
Exemple #4
0
 public function add($alias, $driver = NULL, $value = NULL, array $options = NULL)
 {
     // If Formo object was passed, add it as a subform
     if ($driver instanceof Formo) {
         return $this->add_subform($driver);
     }
     if ($alias instanceof Formo) {
         return $this->add_subform($alias->alias($driver));
     }
     if ($value instanceof Formo) {
         return $this->add_subform($value->alias($alias)->set('driver', $driver));
     }
     $orig_options = $options;
     $options = func_get_args();
     $options = self::args(__CLASS__, __FUNCTION__, $options);
     // If a driver is named but not an alias, make the driver text and the alias the driver
     if (empty($options['driver'])) {
         $options['driver'] = Arr::get($this->config, 'default_driver', 'text');
     }
     // Allow loading rules, callbacks, filters upon adding a field
     $validate_options = array('rule', 'trigger', 'filter');
     // Create the array
     $validate_settings = array();
     foreach ($validate_options as $option) {
         $option_name = Inflector::plural($option);
         if (!empty($options[$option_name])) {
             $validate_settings[$option] = $options[$option_name];
             unset($options[$option_name]);
         }
     }
     // Create the new field
     $field = Ffield::factory($options);
     $this->append($field);
     // Add the validation rules
     foreach ($validate_settings as $method => $array) {
         foreach ($array as $callback => $opts) {
             $args = array(NULL, $callback, $opts);
             call_user_func_array(array($field, $method), $args);
         }
     }
     return $this;
 }