0

Having the SQL in the XML file to build custom inputs is great, I just can't figure it out how to link the value based on another imput... Say you have the Language Selection, then you want that value to be use on another custom input to select all where language is equal to the selected language
You have this at all times in all editing forms, content, category, modules...etc,

<field
    name="language"
    type="contentlanguage"
    label="JFIELD_LANGUAGE_LABEL">
    <option value="*">JALL</option>
</field>

That is your language selector, so when creating or editing a category you have that value always with a pre-set value from "*" to "en-GB" or whatever language you might have, so we want that value to be use from another custom input...

<field
    name="artId"
    label="Article"
    description="Select Article"
    layout="joomla.form.field.list-fancy-select"
    type="sql"
    query="SELECT id, title, language FROM #__content"
    key_field="id"
    value_field="title"
    sql_default_language="en-GB"
    sql_default_state="1"
    sql_default_access="1"
    required="false"
    header="Please select your option"
/>

Notice this sql_default_language="en-GB", there is where the value from the language input is needed, so, how do I pull that value into this new input?
Thank you.

1 Answer 1

1

You can do this inside the model, after fetching the form:

$form->setFieldAttribute('artId', 'sql_default_language', $form->getValue('language'));

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.