public function display_field(ContactField $field)
 {
     $fieldset = $field->get_fieldset();
     $regex = $field->get_regex();
     switch ($regex) {
         case 1:
             $field_class = 'FormFieldNumberEditor';
             $display_constraint = false;
             break;
         case 4:
             $field_class = 'FormFieldMailEditor';
             $display_constraint = false;
             break;
         case 5:
             $field_class = 'FormFieldUrlEditor';
             $display_constraint = false;
             break;
         case 8:
             $field_class = 'FormFieldTelEditor';
             $display_constraint = false;
             break;
         default:
             $field_class = 'FormFieldTextEditor';
             $display_constraint = true;
             break;
     }
     $fieldset->add_field(new $field_class($field->get_field_name(), $field->get_name(), $field->get_default_value(), array('required' => (bool) $field->is_required(), 'description' => $field->get_description()), $display_constraint ? array($this->constraint($regex)) : array()));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $this->update_fields($request);
     $fields_number = 0;
     foreach ($this->config->get_fields() as $id => $properties) {
         $field = new ContactField();
         $field->set_properties($properties);
         $this->view->assign_block_vars('fields_list', array('C_DELETE' => $field->is_deletable(), 'C_READONLY' => $field->is_readonly(), 'C_DISPLAY' => $field->is_displayed(), 'C_REQUIRED' => $field->is_required(), 'ID' => $id, 'NAME' => $field->get_name(), 'U_EDIT' => ContactUrlBuilder::edit_field($id)->rel()));
         $fields_number++;
     }
     $this->view->put_all(array('C_FIELDS' => $fields_number, 'C_MORE_THAN_ONE_FIELD' => $fields_number > 1));
     return new AdminContactDisplayResponse($this->view, LangLoader::get_message('admin.fields.manage.page_title', 'common', 'contact'));
 }
 public function display_field(ContactField $field)
 {
     $fieldset = $field->get_fieldset();
     $options = array();
     $default_values = array();
     $i = 0;
     foreach ($field->get_possible_values() as $name => $parameters) {
         $options[] = new FormFieldMultipleCheckboxOption($name, stripslashes($parameters['title']));
         if ($parameters['is_default']) {
             $default_values[] = $name;
         }
         $i++;
     }
     $fieldset->add_field(new FormFieldMultipleCheckbox($field->get_field_name(), $field->get_name(), $default_values, $options, array('required' => (bool) $field->is_required(), 'description' => $field->get_description())));
 }
 public function display_field(ContactField $field)
 {
     $fieldset = $field->get_fieldset();
     $options = array();
     $i = 0;
     $default = '';
     foreach ($field->get_possible_values() as $name => $parameters) {
         $options[] = new FormFieldRadioChoiceOption(stripslashes($parameters['title']), $name);
         if ($parameters['is_default']) {
             $default = $name;
         }
         $i++;
     }
     if (empty($default)) {
         $options = array_merge(array(new FormFieldSelectChoiceOption('', '')), $options);
         $default = '';
     }
     $fieldset->add_field(new FormFieldRadioChoice($field->get_field_name(), $field->get_name(), $default, $options, array('required' => (bool) $field->is_required(), 'description' => $field->get_description())));
 }
 public function display_field(ContactField $field)
 {
     $fieldset = $field->get_fieldset();
     $fieldset->add_field(new FormFieldShortMultiLineTextEditor($field->get_field_name(), $field->get_name(), $field->get_default_value(), array('required' => (bool) $field->is_required(), 'rows' => 10, 'cols' => 80, 'description' => $field->get_description()), array($this->constraint($field->get_regex()))));
 }
Ejemplo n.º 6
0
 public function display_field(ContactField $field)
 {
     $fieldset = $field->get_fieldset();
     $fieldset->add_field(new FormFieldDate($field->get_field_name(), $field->get_name(), null, array('description' => $field->get_description(), 'required' => (bool) $field->is_required())));
 }