本文整理汇总了PHP中Jam::form方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::form方法的具体用法?PHP Jam::form怎么用?PHP Jam::form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::form方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
public function form($form = NULL)
{
if ($form !== NULL) {
$this->_form = $form;
return $this;
}
if (!$this->_form) {
$this->_form = Jam::form(Jam::build('tart_filter', $this->data()), 'tart_filter');
}
return $this->_form;
}
示例2: test_fields_for
public function test_fields_for()
{
$empty_form = Jam::form(Jam::build('test_post'));
$empty_blog_form = $empty_form->fields_for('test_blog');
$this->assertEquals('test_blog[%s]', $empty_blog_form->prefix());
$this->assertEquals('test_blog_field', $empty_blog_form->default_id('field'));
$this->assertEquals('test_blog[field]', $empty_blog_form->default_name('field'));
$this->assertEquals(array('id' => 'test_blog_field', 'name' => 'test_blog[field]'), $empty_blog_form->default_attributes('field'));
$blog_form = $this->form->fields_for('test_blog');
$this->assertEquals('test_blog[%s]', $blog_form->prefix());
$this->assertEquals('test_blog_field', $blog_form->default_id('field'));
$this->assertEquals('test_blog[field]', $blog_form->default_name('field'));
$this->assertEquals(array('id' => 'test_blog_field', 'name' => 'test_blog[field]'), $blog_form->default_attributes('field'));
$this->assertGreaterThan(1, count($this->post->test_tags), 'Should have some tags to test on');
foreach ($this->post->test_tags as $i => $test_tag) {
$tag_form = $this->form->fields_for('test_tags', $i);
$this->assertEquals("test_tags[{$i}][%s]", $tag_form->prefix());
$this->assertEquals("test_tags_{$i}_field", $tag_form->default_id('field'));
$this->assertEquals("test_tags[{$i}][field]", $tag_form->default_name('field'));
$this->assertEquals(array('id' => "test_tags_{$i}_field", 'name' => "test_tags[{$i}][field]"), $tag_form->default_attributes('field'));
}
}
示例3: setUp
public function setUp()
{
parent::setUp();
$this->post = Jam::build('test_post')->load_fields(array('id' => 1, 'name' => 'First Post', 'slug' => 'first-post', 'status' => 'draft', 'test_blog_id' => 1));
$this->form = Jam::form($this->post, 'general');
}
示例4: array
<?php
$form = Jam::form($session, 'tart_general');
?>
<div class="fluid-row">
<div class="span6 offset3">
<?php
echo Form::open(Tart::uri('session', 'new'), array('class' => 'form-horizontal'));
?>
<div class="control-group">
<div class="controls">
<h3>Login</h3>
</div>
</div>
<?php
echo $form->row('input', 'email');
?>
<?php
echo $form->row('password', 'password');
?>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<?php
echo $form->checkbox('remember_me');
?>
Remember me
</label>
</div>
</div>
<div class="form-actions">
示例5: fields_for
/**
* Create a nested form for a child association of the model, assigning the correct prefix
*
* @param string $name of the association
* @param int $index an index id of a collection (if the association if a colleciton)
* @return Jam_Form
*/
public function fields_for($name, $index = NULL)
{
$object = $this->object()->{$name};
if ($index !== NULL) {
if (is_numeric($index) and $object[$index]) {
$object = $object[$index];
} else {
$object = $object->build();
}
} elseif (!$object) {
$object = $this->object()->build($name);
}
$new_prefix = Jam_Form::generate_prefix($this->prefix(), $name, $index);
return Jam::form($object, get_class($this))->prefix($new_prefix);
}