/**
  * Instantiate an Input object for the supplied field call setAllowEmpty()
  * depending upon whether the field is required.
  *
  * @param Field $field
  * @return Input
  */
 protected function instantiateInput(Field $field)
 {
     $input = new Input($field->getControlName());
     if ($field->isRequired() && !$field->isType('boolean')) {
         $input->setAllowEmpty(false);
     } else {
         $input->setAllowEmpty(true);
     }
     return $input;
 }
Example #2
0
 /**
  * Use the supplied \Dewdrop\Db\Field object to set the helper's options
  * and then render the input.
  *
  * @param Field $field
  * @param array $options
  * @return string
  */
 protected function directField(Field $field, array $options = array())
 {
     $fieldDefaults = array('name' => $field->getControlName(), 'id' => $field->getHtmlId(), 'value' => $field->getValue());
     return $this->directArray($fieldDefaults + $options);
 }
Example #3
0
 public function direct(Field $field, Field $cascadeFrom)
 {
     $this->view->headScript()->appendFile($this->view->bowerUrl('/dewdrop/www/js/cascade-select.js'));
     return $this->view->select(['name' => $field->getControlName(), 'id' => $field->getHtmlId(), 'options' => [], 'value' => $field->getValue(), 'attributes' => ['data-cascade-options' => $this->view->encodeJsonHtmlSafe($field->getOptionGroups()->fetchJsonWrapper()), 'data-cascade-from' => '#' . $cascadeFrom->getHtmlId(), 'data-cascade-title' => "Choose a {$cascadeFrom->getLabel()}...", 'data-show-blank' => true, 'data-blank-title' => '', 'data-value' => $field->getValue()]]);
 }
Example #4
0
 /**
  * Render the image picker using the supplied Field object.
  *
  * @param Field $field
  * @return string
  */
 public function directField(Field $field)
 {
     return $this->directArray(array('name' => $field->getControlName(), 'id' => $field->getHtmlId(), 'value' => $field->getValue()));
 }
Example #5
0
 /**
  * Add a field, optionally changing its control name to disambiguate it
  * from other fields with the same control name on this page.
  *
  * @param DbField $field
  * @param string $groupName
  * @return \Dewdrop\Fields\Edit
  */
 public function add(DbField $field, $groupName = null)
 {
     if (null === $groupName) {
         $this->fields[$field->getControlName()] = $field;
     } else {
         $fieldIndex = $groupName . ':' . $field->getName();
         $field->setControlName($fieldIndex);
         $this->fields[$fieldIndex] = $field;
     }
     $this->inputFilter->add($field->getInputFilter());
     return $this;
 }
Example #6
0
 /**
  * Use a \Dewdrop\Db\Field object to set the editor's id and content.
  *
  * @param Field $field
  * @return string
  */
 public function directField(Field $field)
 {
     $field->getFilterChain()->attach(new StripSlashes());
     return $this->directArray(array('name' => $field->getControlName(), 'value' => $field->getValue(), 'id' => $field->getHtmlId()));
 }