extractSubmittedData() public method

public extractSubmittedData ( Symfony\Component\Form\FormInterface $form )
$form Symfony\Component\Form\FormInterface
Esempio n. 1
0
    /**
     * {@inheritdoc}
     */
    public function collectSubmittedData(FormInterface $form)
    {
        $hash = spl_object_hash($form);

        if (!isset($this->dataByForm[$hash])) {
            // field was created by form event
            $this->collectConfiguration($form);
            $this->collectDefaultData($form);
        }

        $this->dataByForm[$hash] = array_replace(
            $this->dataByForm[$hash],
            $this->dataExtractor->extractSubmittedData($form)
        );

        // Count errors
        if (isset($this->dataByForm[$hash]['errors'])) {
            $this->data['nb_errors'] += count($this->dataByForm[$hash]['errors']);
        }

        foreach ($form as $child) {
            $this->collectSubmittedData($child);

            // Expand current form if there are children with errors
            if (empty($this->dataByForm[$hash]['has_children_error'])) {
                $childData = $this->dataByForm[spl_object_hash($child)];
                $this->dataByForm[$hash]['has_children_error'] = !empty($childData['has_children_error']) || !empty($childData['errors']);
            }
        }
    }
 public function testExtractSubmittedDataRemembersIfNonSynchronized()
 {
     $form = $this->createBuilder('name')->addModelTransformer(new CallbackTransformer(function () {
     }, function () {
         throw new TransformationFailedException('Fail!');
     }))->getForm();
     $form->submit('Foobar');
     $this->assertSame(array('submitted_data' => array('norm' => "'Foobar'", 'model' => 'NULL'), 'errors' => array(), 'synchronized' => 'false'), $this->dataExtractor->extractSubmittedData($form));
 }
 /**
  * {@inheritdoc}
  */
 public function collectSubmittedData(FormInterface $form)
 {
     $hash = spl_object_hash($form);
     if (!isset($this->dataByForm[$hash])) {
         $this->dataByForm[$hash] = array();
     }
     $this->dataByForm[$hash] = array_replace($this->dataByForm[$hash], $this->dataExtractor->extractSubmittedData($form));
     // Count errors
     if (isset($this->dataByForm[$hash]['errors'])) {
         $this->data['nb_errors'] += count($this->dataByForm[$hash]['errors']);
     }
     foreach ($form as $child) {
         $this->collectSubmittedData($child);
     }
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function collectSubmittedData(FormInterface $form)
 {
     $hash = spl_object_hash($form);
     if (!isset($this->dataByForm[$hash])) {
         // field was created by form event
         $this->collectConfiguration($form);
         $this->collectDefaultData($form);
     }
     $this->dataByForm[$hash] = array_replace($this->dataByForm[$hash], $this->dataExtractor->extractSubmittedData($form));
     // Count errors
     if (isset($this->dataByForm[$hash]['errors'])) {
         $this->data['nb_errors'] += count($this->dataByForm[$hash]['errors']);
     }
     foreach ($form as $child) {
         $this->collectSubmittedData($child);
     }
 }