Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Form with non specified number of fields
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Javier Garcia  
View profile  
 More options Sep 10 2012, 4:23 am
From: Javier Garcia <tirengar...@gmail.com>
Date: Mon, 10 Sep 2012 01:23:42 -0700 (PDT)
Local: Mon, Sep 10 2012 4:23 am
Subject: Form with non specified number of fields

Hi,

I need to create a form with dependant selects. The number of selects that
will be shown are not always the same, because not all the levels have
items. I mean, one item can have 3 levels below, and another item in the
same level has 5 levels below.

So, I was thinking in creating a form class, but since the number of fields
is dynamic, how should be that form class?

sf 1.4

Javi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dr. Juan Carlos García Alonso  
View profile  
 More options Sep 11 2012, 12:27 pm
From: Dr. Juan Carlos García Alonso <dr.ju...@gmail.com>
Date: Tue, 11 Sep 2012 12:27:49 -0400
Local: Tues, Sep 11 2012 12:27 pm
Subject: Re: [symfony1] Form with non specified number of fields

I have dealing with that a couple of time before, I have use two ways (I
don´t know if they are the best).
The first, I know all I need, before request the form, for example based in
the user credential. In that case I made the changes at
"lib/form/doctrine/your-form.php"
public function configure()
{
     //Some condition here example
     $user = sfContext::getInstance()->getUser(); //the autenticated user

     if (!$usuario->hasCredential('admin') or
!$usuario->hasCredential('Nacional') or
!$usuario->getGuardUser()->getIsSuperAdmin()):
     {
          $arrAreasId = array(0); $arrAreasNombres = array("Seleccione un
&aacute;rea");
          //some code here to fill the $arrAreasId and $arrAreasNombres
arrays, the example is to big

          //Some configuration here. example
          $this->widgetSchema['Area'] = new
sfWidgetFormChoice(array('choices'=>array_combine($arrAreasId,
$arrAreasNombres),'expanded'=>false)); //I changed the control from a
textbox to a selectbox with my own content
          //Or hide some fields
          unset(  $this['created_at'], $this['updated_at'],
$this['cal_rang_edad']
    );
     }

}

The second way: when I make the page request I still don´t know the
condition yet or I know just in this moment what I need (the conditional)
In this case in your form at:
apps/frontend/modules/mymodule/templates/_form.php

<form action="<?php echo url_for('personal/'.($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; ?>
// some required field here. example
<?php echo $form->renderHiddenFields() ?>
<table>
<?php echo $form['id']->renderRow() //also a required field?>
//some conditional here. example
<?
if($condition==1){
    echo $form['field1']->renderRow()

}else{

   echo $form['field2']->renderRow()
}

)?>
<table>
</form>

*Suppose  the $condition var was defined in the accion.class.php file of
that module, example
  public function executeNew(sfWebRequest $request)
  {
    $this->form = new dptoForm();
    $condition = 1; // define your condition here. Make the steps you need
to get it.
  }

and
  public function executeEdit(sfWebRequest $request)
  {
    $this->forward404Unless($dpto =
Doctrine_Core::getTable('dpto')->find(array($request->getParameter('id'))),
sprintf('Object dpto does not exist (%s).', $request->getParameter('id')));
    $this->form = new dptoForm($dpto);
    $condition = 0; // define your condition here . Make the steps you need
to get it.
  }

I hope this help.
Excuse my english please
2012/9/10 Javier Garcia <tirengar...@gmail.com>

--
Me gustaría cambiar el mundo
Pero no encuentro el código fuente

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »