Hidden button
#1
Posted 01 May 2010 - 02:47 AM
I want to hide a button in an alternative way one button or the other ... how could I do?
#2
Posted 03 May 2010 - 03:10 AM
for more help you need to show how you create the buttons and what would be the first view (both buttons visible, or only one of them)
#3
Posted 03 May 2010 - 03:54 AM
mdomba, on 03 May 2010 - 03:10 AM, said:
for more help you need to show how you create the buttons and what would be the first view (both buttons visible, or only one of them)
My code is:
<div class="row buttons" >
<?php echo CHtml::submitButton('Inserimento Docente', array('submit' => '/tirocini/index.php?r=docente/create&id='.$model->ANAGRA_ID.'')); ?>
<?php echo CHtml::submitButton('Inserimento Studente', array('submit' => '/tirocini/index.php?r=studente/create&id='.$model->ANAGRA_ID.'')); ?>
</div>
#4
Posted 03 May 2010 - 04:04 AM
Do you have two different controllers (docente and studente) that calls the same view?
P.S. when you insert your code enclose it with the [ code ] tag... like this: [code ]... your code... [/code ]
([code ] - without spaces
#5
Posted 03 May 2010 - 04:16 AM
mdomba, on 03 May 2010 - 04:04 AM, said:
Do you have two different controllers (docente and studente) that calls the same view?
P.S. when you insert your code enclose it with the [ code ] tag... like this: [code ]... your code... [/code ]
([code ] - without spaces
Yes I have 2 different controller STUDENTE_CONTROLLER and DOCENTE_CONTROLLER
My situation is that:
I initially have a menu choice where I choose to list a student or teacher.
The problem is that the initial form of both is the same with that is completed by entering the personal details of the person from whom I bring ANAGRA_ID.
Now even after I entered the data in the db I load a new form depending on whether I enter a student or teacher.
And here I want to hide a button depending on who I need to enter.
How can I do?
#6
Posted 03 May 2010 - 04:37 AM
$this->render('create',array(
'model'=>$model,
'tipo'=>'STUDENTE', //.. or you can use only first letter like 'tipo'=>'S'
));
*note the use of the [code ] for more readable code in the forum
now in the view you can use a simple
if($tipo=="STUDENTE") //.. or $tipo=="S" button for studente else button for docente
#7
Posted 03 May 2010 - 05:01 AM
mdomba, on 03 May 2010 - 04:37 AM, said:
$this->render('create',array(
'model'=>$model,
'tipo'=>'STUDENTE', //.. or you can use only first letter like 'tipo'=>'S'
));
*note the use of the [code ] for more readable code in the forum
now in the view you can use a simple
if($tipo=="STUDENTE") //.. or $tipo=="S" button for studente else button for docente
Sorry but I did not understand a thing ..
'Type' => 'STUDENT', .. in this line of code STUDENTE does not refer to a field in the student model...but is a random string ... ... right?
#8
Posted 03 May 2010 - 05:21 AM
kitty10, on 03 May 2010 - 05:01 AM, said:
'Type' => 'STUDENT', .. in this line of code STUDENTE does not refer to a field in the student model...but is a random string ... ... right?
Actually I have written 'tipo' not 'type'... that will become a variable ($tipo) in the view that you can use/test
'STUDENTE' is a string value that $tipo will have... and that you can test in the view...
Please read the definitive guide to Yii... http://www.yiiframew...ide/basics.view
#9
Posted 03 May 2010 - 05:36 AM
mdomba, on 03 May 2010 - 05:21 AM, said:
'STUDENTE' is a string value that $tipo will have... and that you can test in the view...
Please read the definitive guide to Yii... http://www.yiiframew...ide/basics.view
Ok I have tried but not work correctly...
Display always the 'docente' button,but never the 'studente' button
The problem for me is that not know before clik button if is student or teacher and so not enter in the if condition and display always the else condition...
In previous form there is no field in which you can tell whether I want to insert a student or teacher...
this code:
$this->render('create',array(
'model'=>$model,
'tipo'=>'STUDENTE'
));
doesn't work if I put the controller student or in the controller of the previous form Anagrafe_controller...I do not know if I was clear
#10
Posted 03 May 2010 - 06:01 AM
how else can you decide which button to display...
#11
Posted 03 May 2010 - 06:38 AM
mdomba, on 03 May 2010 - 06:01 AM, said:
how else can you decide which button to display...
Good question ... .. are days that I think on how.
I do not know how to proceed.
I decide (Administrator) to insert a teacher or a student ... the problem is that I am forced to put two buttons and I somehow hide either.
Let's say I have the previous form only your name, address and sex that are required and anagra_id that use the GET to use the same id.
I really do not know how to do ..help meee
#12
Posted 03 May 2010 - 07:06 AM
If only you can decide (administrator) if it's STUDENTE or DOCENTE than how can a program know what button to show/hide?

Help












