예제 #1
0
 /**
  * Add a FormField
  *
  * @param FormField $formField FormField object to add
  */
 public function addFormField(FormField $formField)
 {
     if (isset($this->fields[$formField->getName()])) {
         throw new SWException(sprintf("Field already exists.\n\tForm: %s\n\tField name: ", $this->name, $formField->getName()));
     }
     $this->fields[$formField->getName()] = $formField;
 }
 public function transform(FormField $field)
 {
     // Look for a performXXTransformation() method on the field itself.
     // performReadonlyTransformation() is a pretty commonly applied method.
     // Otherwise, look for a transformXXXField() method on this object.
     // This is more commonly done in custom transformations
     // We iterate through each array simultaneously, looking at [0] of both, then [1] of both.
     // This provides a more natural failover scheme.
     $transNames = array_reverse(array_values(ClassInfo::ancestry($this->class)));
     $fieldClasses = array_reverse(array_values(ClassInfo::ancestry($field->class)));
     $len = max(sizeof($transNames), sizeof($fieldClasses));
     for ($i = 0; $i < $len; $i++) {
         // This is lets fieldClasses be longer than transNames
         if ($transName = $transNames[$i]) {
             if ($field->hasMethod('perform' . $transName)) {
                 $funcName = 'perform' . $transName;
                 //echo "<li>$field->class used $funcName";
                 return $field->{$funcName}($this);
             }
         }
         // And this one does the reverse.
         if ($fieldClass = $fieldClasses[$i]) {
             if ($this->hasMethod('transform' . $fieldClass)) {
                 $funcName = 'transform' . $fieldClass;
                 //echo "<li>$field->class used $funcName";
                 return $this->{$funcName}($field);
             }
         }
     }
     user_error("FormTransformation:: Can't perform '{$this->class}' on '{$field->class}'", E_USER_ERROR);
 }
예제 #3
0
 /**
  * Add is $Field is required message.
  *
  * @param FormField $field
  * @param $title
  */
 protected function setCustomValidationMessage(FormField $field, $title)
 {
     if (!$field->getCustomValidationMessage()) {
         $message = strip_tags($title) . ' ' . _t('Site.IsRequired', ' is required');
         $field->setCustomValidationMessage($message);
     }
 }
 /**
  * Used for storing the quantity update link for ajax use.
  */
 public function AJAXLinkHiddenField()
 {
     if ($quantitylink = $this->item->setquantityLink()) {
         $attributes = array('type' => 'hidden', 'class' => 'ajaxQuantityField_qtylink', 'name' => $this->MainID() . '_Quantity_SetQuantityLink', 'value' => $quantitylink);
         $formfield = new FormField('hack');
         return $formfield->createTag('input', $attributes);
     }
 }
 /**
  * Used for storing the quantity update link for ajax use.
  */
 function AJAXLinkHiddenField()
 {
     if ($quantitylink = ShoppingCart::set_quantity_item_link($this->item->getProductIDForSerialization(), null, $this->parameters)) {
         $attributes = array('type' => 'hidden', 'class' => 'ajaxQuantityField_qtylink', 'name' => $this->item->MainID() . '_Quantity_SetQuantityLink', 'value' => $quantitylink);
         $formfield = new FormField('hack');
         return $formfield->createTag('input', $attributes);
     }
 }
 /**
  * @return FormField
  */
 public function addPart(FormField $part)
 {
     if (strval($part->getName()) === '') {
         $part->setName(sprintf('%s-%s', $this->getName(), count($this->parts)));
     }
     $part->setAttribute('data-part', count($this->parts));
     $this->parts[] = $part;
     return $this;
 }
예제 #7
0
 public function getFormat()
 {
     $fields = AddressFormat::getOrderedAddressFields($this->country->id, true, true);
     $required = array_flip(AddressFormat::getFieldsRequired());
     $format = ['id_address' => (new FormField())->setName('id_address')->setType('hidden'), 'id_customer' => (new FormField())->setName('id_customer')->setType('hidden'), 'back' => (new FormField())->setName('back')->setType('hidden'), 'token' => (new FormField())->setName('token')->setType('hidden'), 'alias' => (new FormField())->setName('alias')->setLabel($this->getFieldLabel('alias'))];
     foreach ($fields as $field) {
         $formField = new FormField();
         $formField->setName($field);
         $fieldParts = explode(':', $field, 2);
         if (count($fieldParts) === 1) {
             if ($field === 'postcode') {
                 if ($this->country->need_zip_code) {
                     $formField->setRequired(true);
                 }
             }
         } elseif (count($fieldParts) === 2) {
             list($entity, $entityField) = $fieldParts;
             // Fields specified using the Entity:field
             // notation are actually references to other
             // entities, so they should be displayed as a select
             $formField->setType('select');
             // Also, what we really want is the id of the linked entity
             $formField->setName('id_' . strtolower($entity));
             if ($entity === 'Country') {
                 $formField->setType('countrySelect');
                 $formField->setValue($this->country->id);
                 foreach ($this->availableCountries as $country) {
                     $formField->addAvailableValue($country['id_country'], $country[$entityField]);
                 }
             } elseif ($entity === 'State') {
                 if ($this->country->contains_states) {
                     $states = State::getStatesByIdCountry($this->country->id);
                     foreach ($states as $state) {
                         $formField->addAvailableValue($state['id_state'], $state[$entityField]);
                     }
                     $formField->setRequired(true);
                 }
             }
         }
         $formField->setLabel($this->getFieldLabel($field));
         if (!$formField->isRequired()) {
             // Only trust the $required array for fields
             // that are not marked as required.
             // $required doesn't have all the info, and fields
             // may be required for other reasons than what
             // AddressFormat::getFieldsRequired() says.
             $formField->setRequired(array_key_exists($field, $required));
         }
         $format[$formField->getName()] = $formField;
     }
     return $this->addConstraints($this->addMaxLength($format));
 }
 /**
  * @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;
 }
 public function __construct($name, $title = null, $value = '', $extension = null, $areaCode = null, $countryCode = null)
 {
     $this->areaCode = $areaCode;
     $this->ext = $extension;
     $this->countryCode = $countryCode;
     parent::__construct($name, $title, $value);
 }
예제 #10
0
 /**
  * Create a new action button.
  * @param action The method to call when the button is clicked
  * @param title The label on the button
  * @param form The parent form, auto-set when the field is placed inside a form 
  * @param extraData A piece of extra data that can be extracted with $this->extraData.  Useful for
  *                  calling $form->buttonClicked()->extraData()
  * @param extraClass A CSS class to apply to the button in addition to 'action'
  */
 function __construct($action, $title = "", $form = null, $extraData = null, $extraClass = '')
 {
     $this->extraData = $extraData;
     $this->extraClass = ' ' . $extraClass;
     $this->action = "action_{$action}";
     parent::__construct($this->action, $title, null, $form);
 }
예제 #11
0
 /**
  * Sets the value of the field.
  *
  * @param string $value The value of the field
  *
  * @throws \InvalidArgumentException When value type provided is not correct
  */
 public function setValue($value)
 {
     if ('checkbox' == $this->type && false === $value) {
         // uncheck
         $this->value = null;
     } elseif ('checkbox' == $this->type && true === $value) {
         // check
         $this->value = $this->options[0];
     } else {
         if (is_array($value)) {
             if (!$this->multiple) {
                 throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name));
             }
             foreach ($value as $v) {
                 if (!in_array($v, $this->options)) {
                     throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->options)));
                 }
             }
         } elseif (!in_array($value, $this->options)) {
             throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->options)));
         }
         if ($this->multiple && !is_array($value)) {
             $value = array($value);
         }
         if (is_array($value)) {
             $this->value = $value;
         } else {
             parent::setValue($value);
         }
     }
 }
 public function Field($properties = array())
 {
     $options = '';
     foreach ($this->getSource() as $value => $title) {
         if (is_array($title)) {
             $options .= "<optgroup label=\"{$value}\">";
             foreach ($title as $value2 => $title2) {
                 $disabled = '';
                 if (array_key_exists($value, $this->disabledItems) && is_array($this->disabledItems[$value]) && in_array($value2, $this->disabledItems[$value])) {
                     $disabled = 'disabled="disabled"';
                 }
                 $selected = $value2 == $this->value ? " selected=\"selected\"" : "";
                 $options .= "<option{$selected} value=\"{$value2}\" {$disabled}>{$title2}</option>";
             }
             $options .= "</optgroup>";
         } else {
             // Fall back to the standard dropdown field
             $disabled = '';
             if (in_array($value, $this->disabledItems)) {
                 $disabled = 'disabled="disabled"';
             }
             $selected = $value == $this->value ? " selected=\"selected\"" : "";
             $options .= "<option{$selected} value=\"{$value}\" {$disabled}>{$title}</option>";
         }
     }
     return FormField::create_tag('select', $this->getAttributes(), $options);
 }
 public function setDisabled($bool)
 {
     parent::setDisabled($bool);
     $this->fieldLatitude->setDisabled($bool);
     $this->fieldLongditude->setDisabled($bool);
     return $this;
 }
 /**
  * Take the latitude/longitude fields and save them to the DataObject.
  * {@inheritdoc}
  */
 public function saveInto(DataObjectInterface $record)
 {
     $record->setCastedField($this->childFieldName('Latitude'), $this->latField->dataValue());
     $record->setCastedField($this->childFieldName('Longitude'), $this->lngField->dataValue());
     $record->setCastedField($this->childFieldName('Zoom'), $this->zoomField->dataValue());
     return $this;
 }
예제 #15
0
 function FieldHolder()
 {
     $config = array('datetimeorder' => $this->getConfig('datetimeorder'));
     $config = array_filter($config);
     $this->addExtraClass(Convert::raw2json($config));
     return parent::FieldHolder();
 }
예제 #16
0
 /**
  * Gets the heading, or label, for the interface, e.g. "Select the categories for this product"
  *
  * @return string
  */
 public function getHeading()
 {
     if (!$this->get('Heading')) {
         return FormField::name_to_label($this->getParentNode()->transform("BedrockComponent")->getName());
     }
     return $this->get('Heading');
 }
예제 #17
0
 /**
  * Gets an array of all areas defined for the current theme that are compatible
  * with pages of type $class
  * @param string $class
  * @return array $areas
  **/
 public function getAreasForPageType($class)
 {
     $areas = $this->getAreasForTheme(null, false);
     if (!$areas) {
         return false;
     }
     foreach ($areas as $area => $config) {
         if (!is_array($config)) {
             continue;
         }
         if (isset($config['except'])) {
             $except = $config['except'];
             if (is_array($except) ? in_array($class, $except) : $except == $class) {
                 unset($areas[$area]);
                 continue;
             }
         }
         if (isset($config['only'])) {
             $only = $config['only'];
             if (is_array($only) ? !in_array($class, $only) : $only != $class) {
                 unset($areas[$area]);
                 continue;
             }
         }
     }
     if (count($areas)) {
         foreach ($areas as $k => $v) {
             $areas[$k] = FormField::name_to_label($k);
         }
         return $areas;
     } else {
         return $areas;
     }
 }
 /**
  * @param array|object $value
  */
 public function setValue($value)
 {
     if (is_object($value)) {
         $value = $value->map('ID', 'Quantity');
     }
     parent::setValue($value);
 }
 public function updateCMSFields(FieldList $fields)
 {
     $extFields = self::$db;
     $fields->removeByName(array_keys($extFields));
     if (!$this->owner->WordpressID) {
         return;
     }
     $compositeFields = array();
     foreach ($extFields as $name => $type) {
         $value = $this->owner->getField($name);
         $compositeFields[$name] = ReadonlyField::create($name . '_Readonly', FormField::name_to_label($name), $value);
     }
     if ($compositeFields) {
         $wordpressCompositeField = ToggleCompositeField::create('WordpressCompositeField', 'Wordpress', $compositeFields)->setHeadingLevel(4);
         if ($fields->fieldByName('Metadata')) {
             $fields->insertBefore($wordpressCompositeField, 'Metadata');
         } else {
             if ($fields->fieldByName('Root')) {
                 $fields->addFieldToTab('Root.Main', $wordpressCompositeField);
             } else {
                 $fields->push($wordpressCompositeField);
             }
         }
     }
 }
예제 #20
0
 public function testErrors()
 {
     $form = Form::create()->add(Primitive::ternary('flag')->setFalseValue('0')->setTrueValue('1'))->add(Primitive::integer('old')->required())->addRule('someRule', Expression::between(FormField::create('old'), '18', '35'));
     //empty import
     $form->import(array())->checkRules();
     //checking
     $expectingErrors = array('old' => Form::MISSING, 'someRule' => Form::WRONG);
     $this->assertEquals($expectingErrors, $form->getErrors());
     $this->assertEquals(Form::MISSING, $form->getError('old'));
     $this->assertEquals(Form::WRONG, $form->getError('someRule'));
     $this->assertTrue($form->hasError('old'));
     $this->assertFalse($form->hasError('flag'));
     //drop errors
     $form->dropAllErrors();
     $this->assertEquals(array(), $form->getErrors());
     //import wrong data
     $form->clean()->importMore(array('flag' => '3', 'old' => '17'))->checkRules();
     //checking
     $expectingErrors = array('flag' => Form::WRONG, 'someRule' => Form::WRONG);
     $this->assertEquals($expectingErrors, $form->getErrors());
     $this->assertTrue($form->hasError('someRule'));
     //marking good and custom check errors
     $form->markGood('someRule')->markCustom('flag', 3);
     $this->assertEquals(array('flag' => 3), $form->getErrors());
     $this->assertFalse($form->hasError('someRule'));
     $this->assertNull($form->getError('someRule'));
     $this->assertEquals(3, $form->getError('flag'));
     //import right data
     $form->dropAllErrors()->clean()->importMore(array('flag' => '1', 'old' => '35'));
     //checking
     $this->assertEquals(array(), $form->getErrors());
 }
 function Link($action = null)
 {
     if ($this->customLink) {
         return Director::baseURL() . 'ObjectSelectorField_Controller/find/?sourceObject=' . $this->sourceObject . '&displayField=' . $this->getDisplayFieldOptions() . '&multi=' . $this->hasMultiSortOptions();
     }
     return parent::Link($action);
 }
예제 #22
0
 public function setValue($val)
 {
     $this->value = $val;
     if (is_array($val)) {
         $this->fieldType->setValue($val['Type']);
         $this->internalField->setValue($val['Internal']);
         $this->externalField->setValue($val['External']);
         $this->emailField->setValue($val['Email']);
         $this->fileField->setValue($val['File']);
         $this->anchorField->setValue($val['Anchor']);
         $this->targetBlankField->setValue(isset($val['TargetBlank']) ? $val['TargetBlank'] : false);
         $this->extraField->setValue($val['Extra']);
         $this->dataObjectField->setValue($val['DataObject']);
     } elseif ($val instanceof WTLink) {
         $this->fieldType->setValue($val->getType());
         $this->internalField->setValue($val->getInternal());
         $this->externalField->setValue($val->getExternal());
         $this->emailField->setValue($val->getEmail());
         $this->fileField->setValue($val->getFile());
         $this->anchorField->setValue($val->getAnchor());
         $this->targetBlankField->setValue($val->getTargetBlank());
         $this->extraField->setValue($val->getExtra());
         $this->dataObjectField->setValue($val->getDataObject());
     }
     return $this;
 }
 function __construct($name, $title = null, $value = "", $form = null)
 {
     // naming with underscores to prevent values from actually being saved somewhere
     $this->xField = new NumericField("{$name}[x]", _t('GeoCoordinateField.X', 'Longitude'));
     $this->yField = new NumericField("{$name}[y]", _t('GeoCoordinateField.Y', 'Latitude'));
     parent::__construct($name, $title, $value, $form);
 }
예제 #24
0
 protected function handlePost(array $data, $settings = [])
 {
     $post = ['ID' => isset($data['id']) && isset($data['id']['videoId']) ? $data['id']['videoId'] : '0', 'Author' => isset($data['snippet']) && isset($data['snippet']['channelTitle']) ? \FormField::name_to_label($data['snippet']['channelTitle']) : '', 'AuthorID' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? $data['snippet']['channelId'] : 0, 'AuthorURL' => isset($data['snippet']) && isset($data['snippet']['channelId']) ? \Controller::join_links($this->url, 'channel', $data['snippet']['channelId']) : '', 'Title' => isset($data['snippet']) && isset($data['snippet']['title']) ? $data['snippet']['title'] : '', 'Content' => isset($data['snippet']) && isset($data['snippet']['description']) ? $this->textParser()->text($data['snippet']['description']) : '', 'Priority' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? strtotime($data['snippet']['publishedAt']) : 0, 'Posted' => isset($data['snippet']) && isset($data['snippet']['publishedAt']) ? \DBField::create_field('SS_Datetime', strtotime($data['snippet']['publishedAt'])) : null];
     if (isset($data['snippet']) && isset($data['snippet']['thumbnails'])) {
         if (isset($data['snippet']['thumbnails']['high']) && isset($data['snippet']['thumbnails']['high']['url'])) {
             $post['Cover'] = $data['snippet']['thumbnails']['high']['url'];
         } else {
             if (isset($data['snippet']['thumbnails']['medium']) && isset($data['snippet']['thumbnails']['medium']['url'])) {
                 $post['Cover'] = $data['snippet']['thumbnails']['medium']['url'];
             } else {
                 if (isset($data['snippet']['thumbnails']['default']) && isset($data['snippet']['thumbnails']['default']['url'])) {
                     $post['Cover'] = $data['snippet']['thumbnails']['default']['url'];
                 }
             }
         }
     }
     if ($post['ID']) {
         $params = (array) singleton('env')->get('Youtube.video_params');
         if (isset($settings['videoParams'])) {
             $params = array_merge($params, (array) $settings['videoParams']);
         }
         $params['v'] = $post['ID'];
         $post['Link'] = \Controller::join_links($this->url, 'watch', '?' . http_build_query($params));
         $this->setFromEmbed($post);
     }
     if (isset($post['ObjectDescription']) && $post['ObjectDescription'] == $post['Content']) {
         unset($post['ObjectDescription']);
     }
     if (isset($post['Description']) && $post['Description'] == $post['Content']) {
         unset($post['Description']);
     }
     return $post;
 }
예제 #25
0
 /**
  * @param string $name Identifier
  * @param string $title (Optional) Natural language title of the tabset
  * @param Tab|TabSet $unknown All further parameters are inserted as children into the TabSet
  */
 public function __construct($name)
 {
     $args = func_get_args();
     $name = array_shift($args);
     if (!is_string($name)) {
         user_error('TabSet::__construct(): $name parameter to a valid string', E_USER_ERROR);
     }
     $this->name = $name;
     $this->id = $name;
     // Legacy handling: only assume second parameter as title if its a string,
     // otherwise it might be a formfield instance
     if (isset($args[0]) && is_string($args[0])) {
         $title = array_shift($args);
     }
     $this->title = isset($title) ? $title : FormField::name_to_label($name);
     if ($args) {
         foreach ($args as $tab) {
             $isValidArg = is_object($tab) && (!$tab instanceof Tab || !$tab instanceof TabSet);
             if (!$isValidArg) {
                 user_error('TabSet::__construct(): Parameter not a valid Tab instance', E_USER_ERROR);
             }
             $tab->setTabSet($this);
         }
     }
     parent::__construct($args);
 }
 public function Field($properties = array())
 {
     $source = $this->getSource();
     $options = array();
     if ($source) {
         // SQLMap needs this to add an empty value to the options
         if (is_object($source) && $this->emptyString) {
             $options[] = new ArrayData(array('Value' => '', 'Title' => $this->emptyString));
         }
         foreach ($source as $value => $params) {
             $selected = false;
             if ($value === '' && ($this->value === '' || $this->value === null)) {
                 $selected = true;
             } else {
                 // check against value, fallback to a type check comparison when !value
                 if ($value) {
                     $selected = $value == $this->value;
                 } else {
                     $selected = $value === $this->value || (string) $value === (string) $this->value;
                 }
                 $this->isSelected = $selected;
             }
             $disabled = false;
             if (in_array($value, $this->disabledItems) && $params['Title'] != $this->emptyString) {
                 $disabled = 'disabled';
             }
             $options[] = new ArrayData(array('Title' => $params['Title'], 'Value' => $value, 'Selected' => $selected, 'Disabled' => $disabled, 'Attributes' => $this->createOptionAttributes($params)));
         }
     }
     $properties = array_merge($properties, array('Options' => new ArrayList($options)));
     return FormField::Field($properties);
 }
 public function FieldHolder($properties = array())
 {
     Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css');
     Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js');
     if ($this->object && $this->object->ID) {
         $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
         if (strlen($this->object->SourceURL)) {
             $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title'));
             $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width'));
             $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height'));
             $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', '');
             $properties['Type'] = HiddenField::create($this->getName() . '[type]', '');
             $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', '');
             $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description'));
             $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class'));
             foreach ($properties as $key => $field) {
                 if ($key == 'ObjectTitle') {
                     $key = 'Title';
                 } elseif ($key == 'ObjectDescription') {
                     $key = 'Description';
                 }
                 $field->setValue($this->object->{$key});
             }
             if ($this->object->ThumbURL) {
                 $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />');
             }
         }
     } else {
         $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL'));
     }
     $field = parent::FieldHolder($properties);
     return $field;
 }
 public function Field($properties = array())
 {
     if (!isset($properties['ID'])) {
         $properties['ID'] = $this->ID();
     }
     if (!isset($properties['Title']) && $this->Title()) {
         $properties['Title'] = $this->Title();
     }
     if (!isset($properties['AttributesHTML'])) {
         $properties['AttributesHTML'] = $this->AttributesHTML;
     }
     if (!isset($properties['NoClose']) && !$this->allowClose) {
         $properties['NoClose'] = true;
     }
     if ((!isset($properties['Trigger']) || isset($properties['TriggerButton'])) && $this->modalTrigger) {
         if ($this->modalTrigger instanceof FormActionLink) {
             $this->modalTrigger->triggerModal($this->ID());
         }
         if ($this->modalTrigger instanceof FormField) {
             $properties['TriggerButton'] = $this->modalTrigger;
         } else {
             $properties['Trigger'] = $this->modalTrigger;
         }
     }
     if (!isset($properties['FieldList']) && $this->children) {
         $properties['FieldList'] = $this->children;
     }
     if (!isset($properties['FooterFields']) && $this->footer) {
         $properties['FooterFields'] = $this->footer;
     }
     return parent::FieldHolder($properties);
 }
예제 #29
0
 /**
  * (non-PHPdoc)
  * @see forms/FormField#setName($name)
  */
 function setName($name)
 {
     // We need to pass through the name change to the underlying value field.
     $this->valueField->setName($name);
     parent::setName($name);
     return $this;
 }
    public function FieldHolder($attributes = array())
    {
        Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
        Requirements::css("registration/css/affiliations.css");
        Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js");
        Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js");
        Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
        $js_scripts = array("themes/openstack/javascript/pure.min.js", "themes/openstack/javascript/jquery.serialize.js", "themes/openstack/javascript/jquery.cleanform.js", "themes/openstack/javascript/jquery.ui.datepicker.validation.package-1.0.1/jquery.ui.datepicker.validation.js", "themes/openstack/javascript/jquery.validate.custom.methods.js", 'registration/javascript/affiliations.js');
        foreach ($js_scripts as $js) {
            Requirements::javascript($js);
        }
        $arrayData = new ArrayData(array('Title' => 'Edit Affiliation'));
        $modal = $arrayData->renderWith('AffiliationModalForm');
        $modal = trim(preg_replace('/\\s\\s+/', ' ', $modal));
        $script = <<<JS

        (function( \$ ){

            \$(document).ready(function() {
                \$('{$modal}').appendTo(\$('body'));
                \$("#edit-affiliation-form").affiliations({
                    storage:'{$this->mode}'
                });
            });


        }( jQuery ));
JS;
        Requirements::customScript($script);
        return parent::FieldHolder($attributes);
    }