/**
  * Get common options for your node-type field form components.
  *
  * @param  NodeTypeField $field
  *
  * @return array
  */
 public function getDefaultOptions(NodeTypeField $field)
 {
     $label = $field->getLabel();
     $devName = '{{ nodeSource.' . StringHandler::camelCase($field->getName()) . ' }}';
     $options = ['label' => $label, 'required' => false, 'attr' => ['data-field-group' => null !== $field->getGroupName() && '' != $field->getGroupName() ? $field->getGroupName() : 'default', 'data-dev-name' => $devName, 'autocomplete' => 'off']];
     if ('' !== $field->getDescription()) {
         $options['attr']['data-desc'] = $field->getDescription();
     }
     if ($field->getMinLength() > 0) {
         $options['attr']['data-min-length'] = $field->getMinLength();
     }
     if ($field->getMaxLength() > 0) {
         $options['attr']['data-max-length'] = $field->getMaxLength();
     }
     return $options;
 }
Example #2
0
 /**
  * Returns an option array for creating a Symfony Form
  * according to a node-type field.
  *
  * @param  NodesSources  $nodeSource
  * @param  NodeTypeField $field
  *
  * @return array
  */
 public function getFormOptionsFromFieldType(NodeTypeField $field)
 {
     $label = $field->getLabel();
     $devName = '{{ nodeSource.' . StringHandler::camelCase($field->getName()) . ' }}';
     switch ($field->getType()) {
         case NodeTypeField::ENUM_T:
             return ['label' => $label, 'placeholder' => 'choose.value', 'required' => false, 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName]];
         case NodeTypeField::DATETIME_T:
             return ['date_widget' => 'single_text', 'date_format' => 'yyyy-MM-dd', 'label' => $label, 'required' => false, 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName, 'class' => 'rz-datetime-field'], 'placeholder' => ['hour' => 'hour', 'minute' => 'minute']];
         case NodeTypeField::DATE_T:
             return ['widget' => 'single_text', 'format' => 'yyyy-MM-dd', 'label' => $label, 'required' => false, 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName, 'class' => 'rz-date-field'], 'placeholder' => ''];
         case NodeTypeField::INTEGER_T:
             return ['label' => $label, 'required' => false, 'constraints' => [new Type('integer')], 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName]];
         case NodeTypeField::EMAIL_T:
             return ['label' => $label, 'required' => false, 'constraints' => [new \Symfony\Component\Validator\Constraints\Email()], 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName]];
         case NodeTypeField::DECIMAL_T:
             return ['label' => $label, 'required' => false, 'constraints' => [new Type('double')], 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName]];
         case NodeTypeField::COLOUR_T:
             return ['label' => $label, 'required' => false, 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName, 'class' => 'colorpicker-input']];
         case NodeTypeField::GEOTAG_T:
             return ['label' => $label, 'required' => false, 'attr' => ['data-desc' => $field->getDescription(), 'data-dev-name' => $devName, 'class' => 'rz-geotag-field']];
         case NodeTypeField::MARKDOWN_T:
             return ['label' => $label, 'required' => false, 'attr' => ['class' => 'markdown_textarea', 'data-desc' => $field->getDescription(), 'data-min-length' => $field->getMinLength(), 'data-max-length' => $field->getMaxLength(), 'data-dev-name' => $devName]];
         default:
             return ['label' => $label, 'required' => false, 'attr' => ['data-desc' => $field->getDescription(), 'data-min-length' => $field->getMinLength(), 'data-max-length' => $field->getMaxLength(), 'data-dev-name' => $devName]];
     }
 }
Example #3
0
 /**
  * @return string
  */
 public function getSetterName()
 {
     return StringHandler::camelCase('set ' . $this->getName());
 }