예제 #1
0
 public function testIdentifierFieldNotSetAutomaticallyWhenAlreadySet()
 {
     $group = new Group();
     $field = new FauxField();
     $field->setName('my_field');
     $wrongField = new FauxField();
     $wrongField->setName('wrong_field');
     $group->add($field)->setIdentifierField('my_field');
     $group->add($wrongField);
     $this->assertSame($field, $group->getIdentifierField());
 }
예제 #2
0
파일: Form.php 프로젝트: mothership-ec/cog
 /**
  * Add a group of fields to the form.
  *
  * @param Group $group
  */
 protected function _addGroup(Group $group)
 {
     $values = array();
     foreach ($group->getFields() as $name => $field) {
         $values[$name] = $field->getValue();
     }
     $builder = $this->_factory->createNamedBuilder($group->getName(), 'form', $values);
     foreach ($group->getFields() as $field) {
         $field->getFormField($builder);
     }
     $this->_builder->add($builder, 'form', ['label' => $group->getLabel()]);
 }
 protected function _appendGroup(Field\Group $group, $sequence = null)
 {
     foreach ($group->getFields() as $field) {
         $this->_appendField($field, $group->getName(), $sequence);
     }
 }
예제 #4
0
 /**
  * Get a new instance of a group field.
  *
  * @param  string      $name  The name to use for the group
  * @param  string|null $label The optional label for the group
  *
  * @return Group
  */
 public function getGroup($name, $label = null)
 {
     $label = $label ?: ucfirst($name);
     $group = new Group();
     $group->setName($name)->setLabel($label);
     $group->setTranslationKey($this->_baseTransKey);
     return $group;
 }