Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Select boxes to array
First the simplest option, which works fine
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
I can save these values in an array by using this
What If i have a large number of the select boxes like below
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
How do i save all these values in the array?
The way i know is to generate a unique name for all the select boxes and then cycle through them one by one and store them. Is there a better way of doing this.
Can I pass all of them to createNugget function at once.
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
I can save these values in an array by using this
function createNugget() {
$NewNugget = array(
'position' => ForceIncomingString('Position', '');,
'weight' => ForceIncomingInt('Weight', 0);,
);}
What If i have a large number of the select boxes like below
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
[Frozen]
Header
content
Sidebar
Footer
pageend
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
How do i save all these values in the array?
The way i know is to generate a unique name for all the select boxes and then cycle through them one by one and store them. Is there a better way of doing this.
Can I pass all of them to createNugget function at once.
0
This discussion has been closed.
Comments
$arr = array();$n=1; foreach ($_POST) { $arr[$n]['position'] = $_POST[$n."_position"]; $arr[$n]['weight'] = $_POST[$n."_weight"]; }
this is of course a simplified example
$this->PositionSelect = $this->Context->ObjectFactory->NewObject($this->Context, 'Select'); $this->PositionSelect->Name = 'Position'; $this->PositionSelect->AddOption('none', $this->Context->GetDefinition('none')); $this->PositionSelect->AddOption('header', $this->Context->GetDefinition('header')); $this->PositionSelect->AddOption('content', $this->Context->GetDefinition('content')); $this->PositionSelect->SelectedValue = htmlspecialchars($NuggetMng->Nugget[$GLOBALS['NuggetMng']->SentNuggetIndex]['position']);
So can I use just one select box, but different names like Position[1], Position[2] etc. or no
Or they have to be completely new instances
Here is where i mentioned why I'm doing this. in case you want to know the details
Nugget Management
@Sirnot. IN your Page Management extension. When i click save u call the CreateTabs() function that stores the names of the inputfields and select fields passes them on to SaveTabs() function and ur done.
In my case with all these Position and Weight select fields. How will I call the CreateTabs function? The PageSetting Variable will now contain an Array of Position and Weight?
Here it is http://lussumo.com/community/discussion/5935/nuggets-management-alpha-release/
you can download it and try it out.
another option would be to have each select as an array named after the nugget id it refers to. eg. then you'd loop through the post vars ( while( list($nugget_id, $arr) = each($_POST) ) ) and, after verifying the data, assign the nugget with id $nugget_id to values $arr['position']/$arr['weight'].
and btw, in regard to the page selection, you could also use a multiselect input field.