mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
implementing serializeForm() in Prototype engine.
This commit is contained in:
parent
def4c98a08
commit
dda6c93529
2 changed files with 42 additions and 2 deletions
|
@ -281,5 +281,24 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
|
|||
$this->selection = $slider;
|
||||
return $out;
|
||||
}
|
||||
/**
|
||||
* Serialize the form attached to $selector.
|
||||
*
|
||||
* @param array $options Array of options.
|
||||
* @return string Completed serializeForm() snippet
|
||||
* @see JsHelper::serializeForm()
|
||||
**/
|
||||
function serializeForm($options = array()) {
|
||||
$options = array_merge(array('isForm' => false, 'inline' => false), $options);
|
||||
$selection = $this->selection;
|
||||
if (!$options['isForm']) {
|
||||
$selection = '$(' . $this->selection . '.form)';
|
||||
}
|
||||
$method = '.serialize()';
|
||||
if (!$options['inline']) {
|
||||
$method .= ';';
|
||||
}
|
||||
return $selection . $method;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -2,8 +2,6 @@
|
|||
/**
|
||||
* PrototypeEngine TestCase
|
||||
*
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
|
@ -272,5 +270,28 @@ class PrototypeEngineHelperTestCase extends CakeTestCase {
|
|||
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {axis:"horizontal", onChange:onComplete, onSlide:onChange, sliderValue:4});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test the serializeForm implementation.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testSerializeForm() {
|
||||
$this->Proto->get('#element');
|
||||
$result = $this->Proto->serializeForm(array('isForm' => true));
|
||||
$expected = '$("element").serialize();';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Proto->serializeForm(array('isForm' => true, 'inline' => true));
|
||||
$expected = '$("element").serialize()';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Proto->serializeForm(array('isForm' => false));
|
||||
$expected = '$($("element").form).serialize();';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Proto->serializeForm(array('isForm' => false, 'inline' => true));
|
||||
$expected = '$($("element").form).serialize()';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue