Hi! I'm completely lost about ajax and javascript. I have to forms (enterprise and category). I want a button in the enterprise form that makes a new window or popup with a category form. I would be greatful if anybody could show me how this can be done. I'm completely lost. Here is what I did:
In enterprise template Form.php <div id="popupAddNewCategory"> <a href="#" style="color:#000" onClick="popupAddNewCategory('<?php echo url_for('empresa/ popupAddNewCategory') ?>');" >Crear un groupe</a> <form id="formAddNewCategory"> </form> </div> In enterprise actions.class.php public function executePopupAddNewCategory(sfWebRequest $request) { //$this->setLayout(false); $this->maVar = 'first level'; $this->form = new BolsadetrabajoCategoryForm(); $parametres = $request->getParameter('categoria'); if($request->isMethod('POST')) { $this->form->bind($parametres); $this->maVar = 'post method'; if ($this->form->isValid()) { $this->maVar = 'isValid()'; $this->form->save(); } } } In popupAddNewCategorySuccess.php <h1><?php echo __('New Categoria') ?></h1> <?php include_stylesheets_for_form($form) ?> <?php include_javascripts_for_form($form) ?> <form action="<?php echo url_for('categoria/'.($form->getObject()- >isNew() ? ' create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form- >getObject()->getId() : '')) ?>" method="post" <?php $form- >isMultipart() and print 'enctype="multipart/form-data" ' ?>> <?php if (!$form->getObject()->isNew()): ?> <input type="hidden" name="sf_method" value="put" /> <?php endif; ?> <div class="formAddNewCategory"> <div class="globalerror"><?php echo $form- >renderGlobalErrors() ?></div> <div class="rowcol"> <div class="leftcol"><?php echo $form['name']- >renderLabel() ?></div> <div class="centercol"> </div> <div class="rightcol"><?php echo $form['name']- >renderError() ?> <?php echo $form['name'] ?></div> </div> <div class="rowcol"> <div class="leftcol"> <?php echo $form->renderHiddenFields() ?> <a href="<?php echo url_for('categoria/index') ?>"><?php echo __('Cancel') ?></a> <?php if (!$form->getObject()->isNew()): ?> <?php echo link_to(__('Delete'), 'categoria/ delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => __('Are you sure?'))) ?> <?php endif; ?></div> <div class="centercol"> </div> <div class="rightcol"><input type="submit" value="<?php echo __('Save') ?>" /></div> </div> </div> </form> ~ And the javascript and ajax is in a .js file under web directory: function popupAddNewCategory(monUrl){ id = "#popupAddNewCategory"; form = "#formAddNewCategory"; $(id).dialog({ bigframe: true, autoOpen: false, height: 300, modal: true, buttons: { 'Crear una categoria': function() { dataString = $(form).serialize(); $.ajax({ type: 'POST', url: monUrl, //url: 'categoria/create', data: dataString, success: function(data){ alert(data); $(form).empty(); $(form).append(data); }, }); return false; }, 'Anular': function() { $(this).dialog('close'); } }, close: function() { } }); $.ajax({ type: 'GET', url: monUrl, success: function(data){ $(form).empty(); $(form).append(data); }, }); $(id).dialog('open'); } What I get is an empty dialog with two buttons. I know something is not right but I'm completely lost. Can anyone help?? Thanks -- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.