Reputation: 335
Seems like a simple thing, but I'm having a hell of time doing it.
I'm sure it's a quick fix... any help would be appreciated.
Here's the code:
<!-- apps/frontend/modules/job/templates/_form.php -->
<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<?php echo form_tag_for($form, '@job') ?>
<table id="job_form">
<tfoot>
<tr>
<td colspan="2">
<input type="submit" value="Preview your job" />
</td>
</tr>
</tfoot>
<tbody>
<?php echo $form ?>
</tbody>
</table>
</form>
Yes, this is straight from the JObeet tutorial... found here: http://www.symfony-project.org/jobeet/1_4/Propel/en/10
With all the helpers, I thought this may be a symfony issue. Apparently not? At any rate, there is no action attributed to this post input method, so I can't use link_to or url_for helpers.
Upvotes: 1
Views: 2371
Reputation: 38137
Firstly update your form_tag_for
function call to include some attributes and give the form an id :
<?php echo form_tag_for($form, '@job', array('id' => 'the_form')) ?>
Then replace your submit button with something like this :
<a href="javascript:{}" onclick="document.getElementById('the_form').submit(); return false;">Submit</a>
As @domi27 suggested - The symfony way - ie using helpers is the following :
<?php echo link_to_function('Submit', "document.getElementById('the_form').submit()") ?>
Upvotes: 2