Hot answers tagged

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 $...
Nagarjun's user avatar
  • 2,991
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 { ...
Lodder's user avatar
  • 26.9k
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. ...
FFrewin's user avatar
  • 19.6k
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', '...
Liz.'s user avatar
  • 1,375
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....
AndyGaskell's user avatar
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 ...
David Hayes's user avatar
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 ...
Rene Korss's user avatar
  • 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 ...
Bathmat's user avatar
  • 492
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/
Walt Sorensen's user avatar
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');
MyFault's user avatar
  • 677
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" ...
n.h.'s user avatar
  • 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 ...
Sharky's user avatar
  • 10.9k
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 ...
Zollie's user avatar
  • 2,896
3 votes
Accepted

Dynamically add option to Jform field

You're already aware of Joomla\CMS\Form\Field\ListField::addOption() method. value is an attribute in the XML so it needs to be passed along with other attributes in the second argument: $this->...
Sharky's user avatar
  • 10.9k
2 votes
Accepted

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

I would recommend using FieldsAttatch for this, see http://www.fieldsattach.com/ for more info. It is not a full on CCK, but a much lighter system that allows you to add fields to the Joomla content ...
AndyGaskell's user avatar
2 votes
Accepted

Loading the options of a select form field via jQuery Ajax

If I rightly remember, you need to update it if any dynamic changes are made. You can do so with the following: jQuery('#jform_student_ids').trigger("liszt:updated"); Hope this helps
Lodder's user avatar
  • 26.9k
2 votes

Using JHtml::_('behavior.formvalidator') in JForm gives empty error messages

The problem is you haven't set the Error messages, so no error message is shown. You need to include: message="This field is required!" You were using description="" and this is shown in the ...
tonypartridge's user avatar
2 votes

How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?

You can create another Registration controller and override the register() behavior. <?php class UsersControllerRegistration2 extends UsersController { public function register() { ...
quokka-web's user avatar
2 votes

How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?

Let me start by saying I do not condone this method, the next time you update Joomla there is a high probability you will undo these changes completely. This is however a working method to do what ...
Terry Carter's user avatar
  • 1,812
2 votes
Accepted

How to set the form validation only for the fields that are shown

I managed to achieve this via setFieldAttribute. In the XML form I removed the field2 required property and set that dynamically in the form as below. echo $this->form->renderField('field1'); ...
Malaiselvan's user avatar
  • 2,721
2 votes
Accepted

How to add attribute to <form> of backend for module

The short answer is there's an "easier" way. The assumption being you need to provide a means for a user to upload a file as part of the core configuration of the module. Since there isn't a ...
Brian Bolli's user avatar
  • 1,416
2 votes

Show Form Field if AJAX-response is false

Well you could attach your hide/show functions within the success parameter of the ajax method. var showMethod = function () { // show method code... } var hideMethod = function () { // hide ...
FFrewin's user avatar
  • 19.6k
2 votes
Accepted

How to use a custom layout with JForm subform fields?

To place a subform (Joomla! 3.6+) within another "master" form and use a custom layout: 1) In the master JForm XML file use the subform field type. <field name= "fieldname" description= "...
nimble's user avatar
  • 418
2 votes
Accepted

How to select predefined options in an custom form list-field?

I had to do the same thing. I copied the list form field code and changed it accordingly, so I have 2 functions: getInput() getOptions() which you have In the getInput function, that's what actually ...
Alex Mehan's user avatar
2 votes

Custom fields "on demand"

If you have used jform then You can use Subform field. Read here more about Subform repeatable field
Sudhir Sapkal's user avatar
2 votes
Accepted

Why does Joomla remove html tags from submitted text even when filter types are set to raw?

Using $_POST as array key in getArray() argument is producing a warning: Warning: Illegal offset type If your form is using form control (normally jform), you can get unfiltered data like this: $...
Sharky's user avatar
  • 10.9k
2 votes
Accepted

How to submit JForm form based on custom dropdown list value change

onchange attribute can be added to the fields in your XML form. E.g. this is used in filter forms: <field name="access" type="accesslevel" label="JOPTION_FILTER_ACCESS" description=...
Sharky's user avatar
  • 10.9k
2 votes

Dynamically removing single JForm option

The small problem with your question is that <option> is not a field attribute but an element in XML, so you cannot set or remove that using methods for field attributes. You can remove however ...
Zollie's user avatar
  • 2,896
2 votes

Dynamically removing single JForm option

So this is what I've done: protected function preprocessForm(JForm $form, $data, $group = '') { $app = JFactory::getApplication(); ... if ($app->isClient('site')) { // ...
Mike's user avatar
  • 341
2 votes

Dynamically removing single JForm option

Another option could be to place the two versions of the field in separate .xml files in your /forms folder and then decide which one to load. If ($option == 1) { $form->loadFile('...
Irata's user avatar
  • 3,597

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