Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

setting values for a hidden input field in a form


  • Please log in to reply
No replies to this topic

#1 petocities

petocities

  • Members
  • 102 posts
  • OFFLINE
  •  
  • Location:Santiago Chile
  • Local time:10:37 PM

Posted 13 May 2009 - 01:43 PM

Hello everyone,

I'm currently working with the symfony 1.2 framework, and I've found it to be most difficult. I don't consider myself a begginer in programming, but I just can't find a way around this framework, heh. the symfony+HTML combo is giving me major headaches!

The problem I cannot solve is that I want to pass a parameter to a hidden input field in a form. The context is as follows:
- There is a form that a certified user has to fill. Specifcly, the admin has to add a user to an organization through this form.
- If the user he wants does not exist, he has to create it first, then add him to the said org.

the path is something like this:
First, from here I redirect to create the new user, given that the one the admin wants does not exist:
// from template.php
<ul class="sf_admin_actions">
				<li class="sf_admin_action_new"><a href="<?php echo url_for("local_pm/new?newLocal_pm=".$member->getId()) ?>"> <?php echo __('New', array(), 'sf_admin') ?> </a></li>
</ul>
What I do, is that I give the ID as a parameter. The same ID i'll be needing next.

Here I want to create the new user, giving him a speific ID to one of his fields:
if($sf_params->get('newLocal_pm')||$sf_params->has($form->getName().'[newLocal_pm]')):
  ?>
	<h1><?php echo __('Admin local partner', array(), 'messages') ?></h1>
	<h3><?php echo __('New partner', array(), 'messages') ?></h3>
  [b]<?php $form->setWidget('local_partner_id',new sfWidgetFormInputHidden()) ?>[/b]  //<-- here goes the parameter
  <?php else: ?>

After that, I just redirect the admin back to the original page so he can continue navigating
if ($request->hasParameter('_save_and_add'))
	  {
		$this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice').' You can add another one below.');

		$this->redirect('@local_partner_member_new');
	  }
	  else
	  {
		if($request->hasParameter($form->getName().'[newLocal_pm]'))
		  $this->redirect('localPartner/10/new?localPartner='.$local_partner_member->getPersonId());
		$this->redirect('@local_partner_member_edit?id='.$local_partner_member->getId());
	  }

I hope this info is enough. If not, I can try to answer whatever questions you ask in order to solve the problem. Also, I hope my issue is not as trivial as my last post, but i'd rather ask foolish questions than be kept by silly issues. Thanks a bunch guys
Posted Image

BC AdBot (Login to Remove)

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users