Symfony\Component\Form\FormBuilder::has PHP Method

has() public method

public has ( $name )
    public function has($name)
    {
        if (isset($this->unresolvedChildren[$name])) {
            return true;
        }

        if (isset($this->children[$name])) {
            return true;
        }

        return false;
    }

Usage Example

Esempio n. 1
0
 /**
  * @throws \RuntimeException
  * @param \Symfony\Component\Form\FormBuilder $formBuider
  * @param  $elementId
  * @return \Symfony\Component\Form\FormBuilder
  */
 public function getChildFormBuilder(FormBuilder $formBuider, $elementId)
 {
     // todo : warning this introduce a bug if the field name = 'field_name',
     //        add a check to field will always be 'fieldName'
     $elements = explode('_', $elementId);
     // always remove the first element : form's name
     array_shift($elements);
     while ($elementName = array_shift($elements)) {
         if (!$formBuider->has($elementName)) {
             throw new \RuntimeException(sprintf('The element `%s` does not exists', $elementName));
         }
         $formBuider = $formBuider->get($elementName);
     }
     return $formBuider;
 }
All Usage Examples Of Symfony\Component\Form\FormBuilder::has