0
As if I do a for return in this options 48 weeks?
<?= $this->Form->input('Semanas', array(
'options' => $semanas,
'empty' => '(choose one)'
)); ?>
0
As if I do a for return in this options 48 weeks?
<?= $this->Form->input('Semanas', array(
'options' => $semanas,
'empty' => '(choose one)'
)); ?>
0
In the Controller, you might have something like that, assuming your action be the very one index()
:
public function index() {
$semanas = array();
for ($i = 1; $i < 49; $i++) {
$semanas[$i] = "$i semana" . ($i > 1 ? "s" : "");
}
$this->set('semanas', $semanas);
}
And the View remains as is, so the value of each option will be numerical corresponding to the number of the week and the text as you mentioned: 1 week, 2 weeks, 3 weeks...
0
You can create a for popular one array, both in the controller as measured voi, and in the view as such:
<?php
$semanas = array();
for($i=1;$i<49;$i++){
$semanas["{$i} semanas"] = "{$i} semanas";
}
echo $this->Form->input('Semanas', array(
'options' => $semanas,
'empty' => '(choose one)'
)); ?>
Browser other questions tagged cakephp
You are not signed in. Login or sign up in order to post.
You could show your controller ?
– Rafael Braga
Do you want to show these weeks how? In numbers same?
– Erlon Charles
Wanted to show "1 week", "2 weeks", etc..
– Roberto Schon
Should the answer be saved as the number of weeks is also that? A option thus
<option value="1 semana">1 semana</option>
. Would that be?– Erlon Charles
Yes, the answer is the number, and the argument would be the number + week(s)
– Roberto Schon