I'm trying to have an AHAH-enabled form with WYSIWYG fields in Drupal 6.
Problem
On this custom form, the user can click a button to add new fieldsets and add fieldsets within those fieldsets (so there is a parent-child nesting situation within the form). The addition and removal of fieldsets is handled via AHAH (and the ahah_helper module). Each of the parent and child fieldsets contain two fields which are text areas replaced by a WYSIWYG editor (with the Wysiwyg module using NicEdit 0.9). The problem is that on any AHAH submit, changes to any of the WYSIWYG fields are ignored. It appears as though the changes to the scripted field are not populated back to the HTML fields before submit, so the original value gets posted.
What I've Tried
My first thought for a solution was when the user clicks any of the AHAH buttons, simply remove all of the WYSIWYG fields with their native functionality. The two approaches I've tried haven't worked.
I can't add a click handler to the AHAH buttons themselves. An AHAH submit can add more such buttons, so I'd need a client-side callback function to bind the function on any new buttons. But I can't do that because Drupal doesn't let me modify or add to the client-side callback.
I can't add a click handler to the form container and let the events bubble up because the submit buttons interrupt event bubbling.
I ran into this same problem. Installing the WYSIWYG CCK Integration module solved if for me.
http://drupal.org/project/wysiwygcck
Related
I am using Ninja form and I have a checkbox field. On click of this checkbox I have two input fields which are displayed. I have to make both the fields as required. How can I make both of them required?
I've used jQuery to add required property but when I click on submit the form is submitted without showing any errors.
I
Know a Employee
Employee Full name
Employee Email
I used the conditional logic extension for showing and hiding the two input fields on checking and unchecking of the Checkbox. Also, Used jQuery for acheiving the same functionality. Expected output, On checking the checkbox, Both the fields should be visible and required before submitting the form
Scrap the extra jQuery, just simply make the fields required using the
provided toggle option
Then setup the conditional logic so that the fields are hidden when they're not checked and vice versa. When the fields are hidden it will act as if they don't exist, meaning you will not be required to fill out the hidden required fields to submit. But when the box is checked and they show again you will have to fill out the fields. If this doesn't work try updating your conditional logic add-on, as I don't think it always worked like this.
I have a widget where dynamic input fields are being inserted by javascript. Also, these fields can be sorted, and moved around.
The combination of these two things causes the Customizer "change" trigger for the widget not to fire, and therefore there is no selective refresh for the preview page.
Is there a way I can tell wp.customize to "re-listen" to all the input fields for a change event after a sort? And also, is there a way to manually fire a selective refresh in wp.customize after I change the sorting order inside a widget?
Changing the sorting order does not cause any input fields to change.
Very basic question here. I'm trying to make a simple form that includes a dropdown list and a submit button, with each dropdown item corresponding to a pdf file. The user must simply select an item and click "submit" and the file will download.
I accomplished this by adding an onClick event to the submit button. HOWEVER, WordPress strips out onClick events. How do I accomplish this in the simplest way in a WordPress site? Thank you!
The simplest method would be to hard code your form into a page template in your theme. Here is a great resource for creating custom page templates: https://www.smashingmagazine.com/2015/06/wordpress-custom-page-templates/
If the code is added to the template, then the onClick will not be stripped out.
I added a field to a node using hook_form_alter and i can see it fine but now i would like of course that the data enterd in that field is also saved. What do i have to do for this to happen?
When you alter the form, you need to also add a form submission handler to the module; in that way, your module would be invoked when the form is being submitted, and you can save the value of the field you added.
If there are more than one button, then it's preferable to add the submission handler to the specific button you need to act upon. Suppose, for example, that the form has two submission buttons: "Save" and "Delete"; if you add the submission handler with $form[#submit][] = "my module_form_submit"; then the submission handler is called even when the "Delete" button is clicked.
As reported in Form buttons can define custom #submit and #validate handlers:
All forms can have "#validate" and "#submit" properties containing lists of validation and submission handlers to be executed when a user submits data. Previously, if a form featured multiple submission buttons to initiate different actions (updating a record versus deleting, for example), it was necessary to check the incoming $form_values['op'] for the name of the clicked button, then execute different code based on its value.
Now, it is possible to define #validate and #submit properties on each individual form button if desired.
When a specific button is used to submit a form, its validation and submission handlers will be used rather than the default form-level ones. If none are specified at the button level, the form-level handlers will be used instead.
Additionally, The 'op' element in the form values is deprecated and should not be relied upon reports:
As discussed above, each button can have "#validate" and "#submit" functions associated with it. Thus, there should be one button that submits the form and which invokes the normal $form_id_validate and $form_id_submit handlers. Any additional buttons which need to invoke different validate or submit functionality should have button-specific functions. Note also that the 'op' element in the form values, corresponding to the button clicked when there are several in a form in Drupal 5.x, should no longer be relied upon and may not be present.
I have this Create Event form (asp.net mvc), and i have to change some parts of the form, depending on user's choice. When the user clicks radio buttons, different user controls (ascx files) should be injected inside the form hopefully using Ajax. Any suggestions to do this?
If you use jQuery you can easily update your form with an ascx or partial html.
The following link could help you further
Wrap your buttons inside forms that are submitted via AJAX (Ajax.BeginForm...). Have the click event submit the form. Using Ajax.BeginForm you can specify the container to be updated with content (UpdateTargetId in the AjaxOptions). Have the form submit to a controller than returns a PartialViewResult based on the form parameters submitted (button values).
If you could have the functionality triggered by links, this is even easier. Just use Ajax.ActionLink and specify the route values necessary to get the proper content. You could, of course, style the links to look like buttons, even radio buttons though that would require some graphics, probably.