/**
  * @param FormField $f
  * @param string $surfix
  * @return static
  */
 protected function setPlaceHolder(FormField $f, $surfix = '')
 {
     $str = $f->Title();
     if ($surfix) {
         $str .= " {$surfix}";
     }
     $f->setAttribute('placeholder', $str);
     return $this;
 }
 /**
  * Create a new nullable field
  * @param $valueField
  * @return NullableField
  */
 function __construct(FormField $valueField, $isNullLabel = null)
 {
     $this->valueField = $valueField;
     $this->isNullLabel = $isNullLabel;
     if (is_null($this->isNullLabel)) {
         // Set a default label if one is not provided.
         $this->isNullLabel = _t('NullableField.IsNullLabel', 'Is Null');
     }
     parent::__construct($valueField->getName(), $valueField->Title(), $valueField->Value(), $valueField->getForm(), $valueField->RightTitle());
     $this->readonly = $valueField->isReadonly();
 }
 /**
  * @param FormField $nonEditableField
  * @param FormField $originalField
  * @param string $fieldname
  * @return CompositeField
  */
 protected function baseTransform($nonEditableField, $originalField, $fieldname)
 {
     /** @var CompositeField $nonEditableField_holder */
     $nonEditableField_holder = CompositeField::create($nonEditableField);
     $nonEditableField_holder->setName($fieldname . '_holder');
     $nonEditableField_holder->addExtraClass('originallang_holder');
     $nonEditableField->setValue($this->original->{$fieldname});
     $nonEditableField->setName($fieldname . '_original');
     $nonEditableField->addExtraClass('originallang');
     $nonEditableField->setTitle(_t('Translatable_Transform.OriginalFieldLabel', 'Original {title}', 'Label for the original value of the translatable field.', array('title' => $originalField->Title())));
     $nonEditableField_holder->insertBefore($originalField, $fieldname . '_original');
     return $nonEditableField_holder;
 }
示例#4
0
 /**
  * Create a new nullable field
  *
  * @param FormField $valueField
  * @param null|string $isNullLabel
  */
 public function __construct(FormField $valueField, $isNullLabel = null)
 {
     $this->valueField = $valueField;
     if (isset($isNullLabel)) {
         $this->setIsNullLabel($isNullLabel);
     } else {
         $this->isNullLabel = _t('NullableField.IsNullLabel', 'Is Null');
     }
     parent::__construct($valueField->getName(), $valueField->Title(), $valueField->Value());
     $this->setForm($valueField->getForm());
     $this->setRightTitle($valueField->RightTitle());
     $this->setReadonly($valueField->isReadonly());
 }
 public function transform(FormField $field)
 {
     if (!$field instanceof GridField) {
         throw new Exception(__CLASS__ . ' requires GridField FormField type.');
     }
     $title = $field->Title();
     $list = $field->getList();
     $config = $field->getConfig();
     $result = MultiRecordField::create($field->getName(), $title, $list);
     // Support: GridFieldExtensions (https://github.com/silverstripe-australia/silverstripe-gridfieldextensions)
     $gridFieldAddNewMultiClass = $config->getComponentsByType('GridFieldAddNewMultiClass')->first();
     if ($gridFieldAddNewMultiClass) {
         $classes = $gridFieldAddNewMultiClass->getClasses($field);
         $result->setModelClasses($classes);
     }
     return $result;
 }
 /**
  * Updates a formfield with the additional metadata specified by this field
  *
  * @param FormField $field
  */
 protected function updateFormField($field)
 {
     // set the error / formatting messages
     $field->setCustomValidationMessage($this->getErrorMessage());
     // set the right title on this field
     if ($this->RightTitle) {
         // Since this field expects raw html, safely escape the user data prior
         $field->setRightTitle(Convert::raw2xml($this->RightTitle));
     }
     // if this field is required add some
     if ($this->Required) {
         // Required validation can conflict so add the Required validation messages as input attributes
         $errorMessage = $this->getErrorMessage()->HTML();
         $field->addExtraClass('requiredField');
         $field->setAttribute('data-rule-required', 'true');
         $field->setAttribute('data-msg-required', $errorMessage);
         if ($identifier = UserDefinedForm::config()->required_identifier) {
             $title = $field->Title() . " <span class='required-identifier'>" . $identifier . "</span>";
             $field->setTitle($title);
         }
     }
     // if this field has an extra class
     if ($this->ExtraClass) {
         $field->addExtraClass($this->ExtraClass);
     }
 }
 public function Title()
 {
     $title = parent::Title();
     // Remove this method override in 4.0
     $decoded = Convert::xml2raw($title);
     if ($decoded !== $title) {
         Deprecation::notice('4.0', 'The FormAction title field should not be html encoded. Use buttonContent to set custom html instead');
         return $decoded;
     }
     return $title;
 }
 /**
  * Returns the field label if showing captcha - used by templates.
  * 
  * @return string Title if field is showing the captcha
  */
 public function Title()
 {
     if ($this->getShowCaptcha()) {
         return parent::Title();
     }
 }