0

In my custom component, under the models folder, is the fields folder which contains the php files for dropdown lists in the .xml by defining its type.

For example, I have a schema.php file in the fields folder, I should specify the type to "schema" correct?

  <field name="report_id" type="schema" class="inputbox"
        label="COM_SUBSCRIPTION_FORM_LBL_FIELDS_REPORTID"
        description="COM_SUBSCRIPTION_FORM_DESC_FIELDS_REPORTID" 
        table = "#__reports_"  key_field="ID" value_field="TITLE" 
   />

When the page reloads, it again calls the schema.php to populate the form field which is of type schema.

I have a dropdown list in my form, which is a custom field type. My form also has a report_Id.

Now I want to use the report_Id as my parameter to filter the content of my dropdown list when the page of the edit form loads.

UPDATE #1:

I have tried using this code in the getInput function of the schema.php file:

$data= JFactory::getApplication()->input->get('jform', array(), 'array');

but it does not return the form together with its inputs when I use var_dump.

2

The easiest way is to use the $_POST inside your field class like:

$input = JFactory::getApplication()->input;

See the reference for JInput.

Though it feels like a bad design I do not see any other option how to pass the data there.

Also you can access the data of your current form in your field class like this:

$formData = $this->form->getData();

You will get a Registry object containing the data.

If you want to update your dropdown list based on your report_Id dynamically then you will need some JS skills.

  • what do you mean use the $_POST then you have provided a syntax for JInput? – Break the Law Feb 4 '15 at 7:49
  • If you follow the reference I gave you will find the answer to your question. – Dmitry Rekun Feb 4 '15 at 7:52
  • please see the update in my post. – Break the Law Feb 4 '15 at 8:11
  • May be your question is slightly wrong... Do you want to make some kind of input field which depends on the same form data? Because it is not so clear - you post your form (reload the same page?) and then you somehow get the form data again on the same page. – Dmitry Rekun Feb 4 '15 at 8:22
  • I apologize if I asked the wrong question, let me explain further: I have a dropdown list in my form, which is a custom field type. My form also has a report_Id. Now i want to use the report_Id as my parameter to filter the content of my dropdown list when the page of the edit form loads. – Break the Law Feb 4 '15 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.