Yii Framework Forum: Hidden button - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Hidden button Rate Topic: -----

#1 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 01 May 2010 - 02:47 AM

I have 2 buttons at the same form.
I want to hide a button in an alternative way one button or the other ... how could I do?
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 May 2010 - 03:10 AM

You can give a unique ID to the buttons and then use jQuery to hide/show them...

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)
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 03 May 2010 - 03:54 AM

View Postmdomba, on 03 May 2010 - 03:10 AM, said:

You can give a unique ID to the buttons and then use jQuery to hide/show them...

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>
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 May 2010 - 04:04 AM

You haven't explained the exact need, from the button source I understand that you need only one button depending if you are adding DOCENTE or STUDENTE but where is defined what are you adding? or How to know what button you want?

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
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 03 May 2010 - 04:16 AM

View Postmdomba, on 03 May 2010 - 04:04 AM, said:

You haven't explained the exact need, from the button source I understand that you need only one button depending if you are adding DOCENTE or STUDENTE but where is defined what are you adding? or How to know what button you want?

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?
0

#6 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 May 2010 - 04:37 AM

So before rendering the view with the buttons you know if it's a STUDENTE or DOCENTE and you can send additional variable to the view like

        $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

Find more about me.... btw. Do you know your WAN IP?
0

#7 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 03 May 2010 - 05:01 AM

View Postmdomba, on 03 May 2010 - 04:37 AM, said:

So before rendering the view with the buttons you know if it's a STUDENTE or DOCENTE and you can send additional variable to the view like

        $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?
0

#8 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 May 2010 - 05:21 AM

View Postkitty10, on 03 May 2010 - 05:01 AM, said:

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?


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
Find more about me.... btw. Do you know your WAN IP?
0

#9 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 03 May 2010 - 05:36 AM

View Postmdomba, on 03 May 2010 - 05:21 AM, said:

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


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
0

#10 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 May 2010 - 06:01 AM

OK I understand that... but then you need to explain me when/where/how do you know if it's a DOCENTE or a STUDENT...

how else can you decide which button to display...
Find more about me.... btw. Do you know your WAN IP?
0

#11 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 03 May 2010 - 06:38 AM

View Postmdomba, on 03 May 2010 - 06:01 AM, said:

OK I understand that... but then you need to explain me when/where/how do you know if it's a DOCENTE or a STUDENT...

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
0

#12 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,340
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 May 2010 - 07:06 AM

I can't help you...

If only you can decide (administrator) if it's STUDENTE or DOCENTE than how can a program know what button to show/hide?
Find more about me.... btw. Do you know your WAN IP?
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users