/**
  * Generate the field ID value
  *
  * @param FormField $field
  * @return string
  */
 public function generateFieldID($field)
 {
     if ($form = $field->getForm()) {
         return sprintf("%s_%s", $this->generateFormID($form), Convert::raw2htmlid($field->getName()));
     }
     return Convert::raw2htmlid($field->getName());
 }
 public function testGetSchemaData()
 {
     $field = new FormField('MyField');
     $schema = $field->getSchemaData();
     $this->assertEquals('MyField', $schema['name']);
     // Make sure the schema data is up-to-date with object properties.
     $field->setName('UpdatedField');
     $schema = $field->getSchemaData();
     $this->assertEquals($field->getName(), $schema['name']);
 }
 /**
  * Handler method called before the FieldList is going to be manipulated.
  *
  * @param FormField $item
  */
 protected function onBeforeInsert($item)
 {
     $this->flushFieldsCache();
     if ($item->getName()) {
         $this->rootFieldList()->removeByName($item->getName(), true);
     }
 }
 /**
  * @param FormField $field
  */
 public function setTimeField($field)
 {
     $expected = $this->getName() . '[time]';
     if ($field->getName() != $expected) {
         throw new InvalidArgumentException(sprintf('Wrong name format for time field: "%s" (expected "%s")', $field->getName(), $expected));
     }
     $field->setForm($this->getForm());
     $this->timeField = $field;
     $this->setValue($this->value);
     // update value
 }