/**
  * @param array $keys
  * @param array $data
  * @param array $customAttributes
  * @param string $result
  * @dataProvider dataProviderSerialize
  */
 public function testSerialize($keys, $data, $customAttributes, $result)
 {
     foreach ($data as $key => $value) {
         $this->abstractForm->setData($key, $value);
     }
     foreach ($customAttributes as $key => $value) {
         $this->abstractForm->addCustomAttribute($key, $value);
     }
     $this->assertEquals($result, $this->abstractForm->serialize($keys));
 }
Example #2
0
 /**
  * Serialize the element.
  *
  * @param string[] $attributes
  * @param string $valueSeparator
  * @param string $fieldSeparator
  * @param string $quote
  * @return string
  */
 public function serialize($attributes = array(), $valueSeparator = '=', $fieldSeparator = ' ', $quote = '"')
 {
     if ($this->isLocked() && !empty($attributes)) {
         $attributes[] = $this->lockHtmlAttribute;
     }
     if (in_array('disabled', $attributes) && !empty($this->_data['disabled'])) {
         $this->_data['disabled'] = 'disabled';
     } else {
         unset($this->_data['disabled']);
     }
     if (in_array('checked', $attributes) && !empty($this->_data['checked'])) {
         $this->_data['checked'] = 'checked';
     } else {
         unset($this->_data['checked']);
     }
     return parent::serialize($attributes, $valueSeparator, $fieldSeparator, $quote);
 }