Пример #1
0
 public function __construct(ICms $cms, Language $language, FormBase $form = null, FormRenderer $form_renderer = null, FieldFactory $field_factory = null)
 {
     $this->cms = $cms;
     $this->language = $language;
     $this->field_factory = $field_factory;
     if ($form) {
         $this->form = $form;
         $this->form->setRenderer($form_renderer);
         if ($this->field_factory) {
             $this->form->filter_fields = $this->field_factory->createFieldSet($this->form, '', 'filters');
             $this->form->filter_fields->fieldset_tag = 'div';
         }
     }
     $this->initialise();
 }
Пример #2
0
 public function createField($type, $name, FieldSet $field_set = null, $caption = null, $help = null, $value = null, $required = false, $maxlength = 0, $attributes = array(), $id = '', $options = array())
 {
     $field = $this->factory->createField($type, $name, $field_set, strlen($id) > 0 ? $id : $name);
     $caption = $caption === null ? $this->getString($name) : $caption;
     $help = $help === null ? $this->getString($name . '_help') : $help;
     $attributes = $attributes === null ? array() : $attributes;
     $field->caption = $caption === null ? '' : $caption;
     if ($maxlength) {
         $attributes['maxlength'] = $maxlength;
     }
     if ($value !== null) {
         if ($type == 'label') {
             $field->setValueRaw($value);
         } else {
             $field->setValue($value);
         }
     }
     $field->required = $required;
     $field->attributes = array_merge($field->attributes, $attributes);
     $field->options = array_merge($field->options, $options);
     $field->help_text = $help === null ? '' : $help;
     return $field;
 }