Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Creating a drop down list within FORM to SHOW (http://www.mysidiaadoptables.com/forum/showthread.php?t=4667)

FounderSim 09-27-2014 12:49 PM

Creating a drop down list within FORM to SHOW
 
My commented line is where my error is.

Ive tried a few other things such as $petField = new buildDropDownList("adopt", "AdoptTypeList");

I tried to see if i could hmm by-pass? the buildDropDownList and access the
buildAdoptTypeList($name) directly so I tried

$petField->add(new buildAdoptTypeList("test"));
$petField = new buildAdoptTypeList("test");

none seem to work. i dunno. any help would be apreaciated.

I can't seem to get an actual error besides " Internal Server Error 500" I can't seem to put error reporting on. I am not sure if mysidia has it turned off by default or its something else.

Code:

        public function add(){
            $mysidia = Registry::get("mysidia");
                $document = $this->document;       
                $document->setTitle("TEST");

                $explorerForm = new Form("addform", "add", "post");

                $petField = new FieldSet("pet");
                $petField->add(new Legend("Adding a Explore Pet"));
                //$petField->add(new buildDropDownList("adopt", "AdoptTypeList"));
                $petField->add(new Comment("Pet Chance:", TRUE, "b"));
                $petField->add(new TextField("textPetPerc"));
                $explorerForm->add($petField);

               

                $myButton = new FieldSet("Test It");
                $myButton->add(new Legend("required?"));
                $myButton->add(new Button("Testing", "submit", "submit"));
                $explorerForm->add($myButton);


FounderSim 09-27-2014 01:17 PM

Code:

                $petField->add(new DropDownList("adopt", "AdoptTypeList"));
seems to work for anyone who needs the answer

=)

FounderSim 09-27-2014 02:17 PM

Quote:

Originally Posted by FounderSim (Post 31243)
Code:

                $petField->add(new DropDownList("adopt", "AdoptTypeList"));
seems to work for anyone who needs the answer

=)


Back again.. It doesn't work afterall. It just displays an empty "drop down list".

How do I get the drop down list with my contents using the more simple version of the form building?

or do I have to go about the more complicated way as seen in other files?

like this way:

sniplet from breedingview.php
Code:

                $settingsForm->buildComment("Breeding System Enabled:  ", FALSE)->buildRadioList("system", $breedingSystem, $breedingSettings->system)
                                        ->buildComment("Breeding Method(heuristic or advanced):  ", FALSE)->buildRadioList("method", $breedingMethod, $breedingSettings->method)
                                        ->buildComment("Ineligible Species(separate by comma):  ", FALSE)->buildTextField("species", ($breedingSettings->species)?implode(",", $breedingSettings->species):"")
                            ->buildComment("Interval/wait-time(days) between successive attempts:        ", FALSE)->buildTextField("interval", $breedingSettings->interval)
                                        ->buildComment("Minimum Level Requirement:        ", FALSE)->buildTextField("level", $breedingSettings->level)


IntoRain 09-27-2014 02:41 PM

Example of how to create a form, a dropdown list with options, display them and then retrieve information from the dropdown list:

PHP Code:

            //create a form: Form(form_name, page_to_redirect, method)
            
$formExample = new Form("exampleform""page_to_send_to_here""post");
            
            
//create a dropdown list object: DropdownList(name)
             
$exampleDropdown = new DropdownList("myList");
              
              
//add options to dropdown list: Option(option_name_displayed, option_value)
                 
$exampleDropdown->add(new Option("Option1""option1")); 
                 
$exampleDropdown->add(new Option("Option2""option2")); 
                 
                 
//add dropdown list to form
                 
$formExample->add($exampleDropdown);
                 
//add button to form
                 
$formExample->add(new Button("Click Me""submit""submit"));
                 
//add form to document to display it
                 
$document->add($formExample);   
                 
                 
//after clicking button to submit form
                 
if($mysidia->input->post("submit")){
                       
//retrieve option selected in the dropdown list, by the dropdown list name
                       
$chosenOption $mysidia->input->post("myList");
                       
$document->add(new Comment("I chose this: {$chosenOption}"));
                 } 


FounderSim 09-27-2014 02:59 PM

Thanks for the reply IntoRain.

I seen I could do it that way. I am trying to use the methods already provided in the class "class_formhelper.php".

This way I don't have to like "recode" whats already there if you can understand. It also seems more reasonable to add new methods to the class_formhelper.php when creating new drop down list with database information then the aproach you mentioned as well.

I just don't know how to properly use them. =(

IntoRain 09-27-2014 03:18 PM

Quote:

Originally Posted by FounderSim (Post 31247)
Thanks for the reply IntoRain.

I seen I could do it that way. I am trying to use the methods already provided in the class "class_formhelper.php".

This way I don't have to like "recode" whats already there if you can understand. It also seems more reasonable to add new methods to the class_formhelper.php when creating new drop down list with database information then the aproach you mentioned as well.

I just don't know how to properly use them. =(

I see. I think the ->build(...) way is more suited to that example you posted. If you want to use this way with the code you already have, we can be a bit hacky about it:

buildAdoptTypeList is a function of the class FormHelper, so you can't do new buildAdoptTypeList(). You need an instance of FormHelper first, then call its functions:

PHP Code:

$exampleHelper = new FormHelper();
$exampleDropdown $exampleHelper->buildAdoptTypeList("myList");//new DropdownList("myList");

//edit: you can do this now:
$petField->add($exampleDropdown); 

And you can add that dropdown $exampleDropdown to the form (or the fieldset you have there)

FounderSim 09-27-2014 04:39 PM

hmm. Interesting. =)

THanks.


You know how I can remove these stupid Internal Server errors? I want to actually see what the real errors are? Its really hard debugging with no error log or actual errors besides a Internal Server Error.


All times are GMT -5. The time now is 08:49 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.