Hot answers tagged

23 votes
Accepted

What are possible filters in Joomla form fields?

The possible filters are: rules (Access Control Rules) unset (Do nothing, thus leaving the return value as null) raw (No filter) int_array (Filter the input as an array of integers) safehtml (Filter ...
  • 26.6k
8 votes
Accepted

JForm showon attribute does not work in admin site

Found what the issue is. I was using getInput function to show the field. $this->form->getInput('field2'); but showon attribute working only if I render the field using renderField function $...
  • 2,981
7 votes
Accepted

How to show a search box inside a list form field

You need to load chosen plugin to style list box fields like this. Load chosen plugin first in your form layout file so that it can add style to your select boxes JHtml::_('formbehavior.chosen', '...
  • 2,981
7 votes
Accepted

How to get module parameters inside helper function and how to get params inside a custom form field type?

1. How to get Modules parameters inside Helper Function You are going all wrong with this. First, you can't use $this inside a static method, because they are independent of any instantiated object. ...
  • 19.6k
7 votes

How to get module parameters inside helper function and how to get params inside a custom form field type?

I much prefer going for the OOP approach. This is what I use in one of my extensions. It's Ajax based so I have a separate function to get the parameters. helper.php: class ModSomethingHelper { ...
  • 26.6k
5 votes
Accepted

Load a Single Admin view with multiple tables and forms

In your model class you want to override the getItem method like so: public function getItem() { $item = parent::getItem(); $item->second_table = $this->getSecondTable($item->...
  • 1,406
5 votes

Filtering list of Users in User form field type

In fact, it is very easy to filtering the list of users in User form field type. First in your manifest you should create a new type for your field, for example userFiltering (see below) <field ...
5 votes
Accepted

How to retrieve values of all the fields with JInput but without jform[]

Yes, you can get the form values without jform. Following is the approach: $data = $jinput->post : returns all post data $something = $jinput->post->get('something', 'default_value', '...
  • 1,365
4 votes
Accepted

Custom XML attributes not showing in HTML markup

Though the XML file and the rendered HTML both call them attributes, there is not a direct pass through of values. Hence, only some attributes make it to the HTML (and some extra attributes are added)....
4 votes
Accepted

Array of form fields

I manged to get a solution as below. <field name="gralev_code][]" type="text" class="width20" label="JSCH_GRALEV_CODE" /> in model.php $formdata = $this->_jinput->get('jform', '...
  • 2,671
4 votes
Accepted

How to work with field type Checkboxes (not checkbox)

My first offering, so please don't shoot me. I've been fighting this one for a while and FINALLY found a solution that works well. Hoping to help others avoid this nightmare. The key piece I was ...
  • 76
4 votes
Accepted

How to add jQuery functionality in the backend of a module?

You will need to create a custom form field for this. So firstly, change the type of the field in your XML like so: <field name="brands" type="brands" label="Foreign Brands" /> Then in your ...
  • 26.6k
4 votes
Accepted

How can I dynamically generate a form's XML from PHP?

I was working with jForm and methods setField() and getFieldset() to set and retrieve the fields, but Joomla was throwing errors. While trying to add a list Joomla was unable to parse the XML until I ...
  • 7,695
4 votes
Accepted

Building Component - Replace "Invalid Field: My Field" with Custom Message

Well fortunately, I got my server side validation working by this way: use Joomla\Registry\Registry; JFormHelper::loadRuleClass('email'); class JFormRuleValidemail extends JFormRuleEmail { ...
  • 1,292
4 votes

Adding Custom Fields to Article Component [Not in attribs field]

I've been using FieldsAttach for this sort of thing, for a few years, the the concepts are clean and eloquent. Brian Teeman explains it well from an integrator point of view in his talk at https://www....
4 votes
Accepted

JFormFieldList in Frontend -> Notice: Array to string conversion

I think you want to use use getOptions(..) not getInput(...) with a JFormFieldList. getInput returns the full <select /> input as a string. getOptions populates the select options with an array ...
4 votes

How to get module parameters inside helper function and how to get params inside a custom form field type?

Your main module file and template file will have $params variable created by Joomla! core. If you have static methods, then pass that variable to function call: class ModTestHelper { public ...
  • 3,208
4 votes

How to use a custom layout with JForm subform fields?

Edited to add subform field type-specific answer: Having looked at it properly, attaching your own layout to the subform field type is super-easy. Create a layouts folder in the same parent ...
  • 492
3 votes
Accepted

Set New XML attribute in custom JFormField

Hi I was able to get it done. I just had to set and get new element. And then, override "setup" function of JFormField class. Following is my code: <?php /* * @package Joomla.Administrator *...
  • 1,292
3 votes

How to access a specific fieldset in a form in my model class?

When using the above command to retrieve server request data, the form fields are organized in a key/value array. Which fieldset is irrelevant to retrieving the data from the array, simply use the ...
  • 1,406
3 votes

Let JForm-Fields be dependent on eachother

Yes this is possible but is a major work around. Joomla has two required verification events. One in he browser and the other on the server just before saving of the form. The browser is the easy part ...
  • 402
3 votes

Joomla JForm SQL-Field: Get condition from global configuration

With the SQL form field type which you are using this is not possible. However you could develop a custom form field type.. Consider subclassing the existing JFormFieldList which will help you a lot. ...
  • 3,703
3 votes

How to retrieve active filter from a custom field form?

Thank God for 5 year old posts and Occam's Razor. The Custom Field has direct access to the form that I was trying to get to!!!! No need to load a model, helper, or otherwise. $MyField1 = $this->...
  • 7,695
3 votes

Insert value to custom field using getForm (setFieldAttribute)

Mea culpa, I had to add the name of the group: $form->setFieldAttribute('test', 'country', 'US', 'personal');
  • 667
3 votes
Accepted

Where can I find a good tutorial and/or example for creating front-end forms in custom components?

Everything you need to get started with JForm for views https://www.ostraining.com/blog/how-tos/development/getting-started-with-jform/
3 votes

Custom 'dynamic' form field creation

I am using the following to achieve something similar to what you need BUT in a plugin. Need to confirm if it is also valid to component. <field name="list_field_name" ...
  • 871
3 votes
Accepted

Manually render filter form fields in layout

Include group name as the second parameter in renderField(), e.g.: echo $this->filterForm->renderField('published', 'filter'); echo $this->filterForm->renderField('limit', 'list'); Or if ...
  • 9,426
3 votes
Accepted

Client side validation - custom event handler not called when user enters the field and leaves it being empty

I deleted my earlier answer, since it was on some points true but not exactly answered the question. My mind was blurred by the question. :) The question is very tricky. Why? Because in the question ...
  • 2,456
2 votes

How to save data from 2 fields as a JSON string to 1 database table field?

Enclose those two fields in a element in your form xml file. <fields label="COM_COMPONENTNAME_FIELDNAME_FIELDSET_LABEL" name="fieldname"> <fieldset label="...
  • 2,981
2 votes
Accepted

How to bookmark articles to user profile?

Personally, I would suggest you create a plugin for this. I'm not going to write it out for you, but will show you the concept. Create your base plugin and to help, follow the documentation here ...
  • 26.6k

Only top scored, non community-wiki answers of a minimum length are eligible