-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contact form: add additional fields such as telephone #207
Comments
A slightly more advanced solution would be to allow the contact form shortcode to include embedded content, with nested shortcodes that define the fields to be included on the form.
This is similar to the solution offered by Jetpack's Grunion contact form. The It should also be possible to implement the bw_contact_field shortcode as a block. |
Notes about other forms plugins wpforms-lite stores the forms in a CPT called |
Note: oik-user has some disabled logic that's similar to oik's contact form. |
At present the |
This was because the The downside of this is that the code will become less extensible since there'll be fewer action hooks invoked. |
Rather than having a fields attribute on the
Since the logic uses
The syntax for the bw_contact_field shortcode allows positional parameters
Examples
produces a required text field labelled
produces a tel field labelled Note: bw_form_field doesn't yet support |
Having achieved a reasonable level of success with the shortcode solution I now want to implement the
|
The challenge here would be to find out how to implement InnerBlocks and ServerSideRendering at the same time. It appears other people have already tried this, quite a while ago.
I suppose I'll have to look at how Jetpack's Contact form blocks work. I assume that there's no Server Side Rendering. |
Rather than use Server Side Rendering I'm going to emulate the form in the block editor. I'm making some progress. The blocks are much faster than when using Server Side Rendering. Notes:
Actually, in the Editor the |
In order to display the Contact form nicely in the block editor I had to replace the table formatting method with grid styling. For the front end this meant changing the form field logic that calls The default contact form is now expected to be a The PHPUnit tests for the contact form will now default to the grid format. Because this change produces different HTML from before the oik version should be changed to v4.9.0 |
Now that I've developed the form to be styled as a grid I can try to introduce a checkbox field that gets a user to confirm they understand how the data they submit might be used. |
I've added the checkbox and written logic to ensure required fields are completed. It's now possible to remove the requirement for the Message field. It can either be present but not required or not even present. |
This could be resolved by adding some logic to retrieve any |
Additional requirements
|
The above styling for the
|
This was done a long time ago prior to oik v2.3. |
I've implemented support for Help and Syntax and generated the shortcode in oik-plugins. There was a problem with the example due to a missing function. Fixed by loading |
I've started adding some logic to set the default values for the
Blanking attributesWhen the user blanks out an attribute it should be unset - reverting to the default
rather than empty strings.
This can be achieved by the following code.
The logic should attempt to cater for the oik-user plugin, which obtains the user's email and name from the author of the current post. In the |
Setting defaultsNotes about the original implementation for the
Setting the defaults for the
The code needs to be tested when the block is used in the Site and Template editor.
|
Q. Can this be implemented using block styles for the Contact field? A. Yes. I've implemented 3 different styles. |
Local tests for these blocks are currently in 5 posts in s.b/cwiccer |
Testing with WordPress 6.2-RC2 in the Site Editor's new Style Book the contact form encounters an error.
|
Currently getting strange styling of the Fields metabox in The problem occurs after the post is saved with the contact form and then re-edited. The contact form is.
|
When the editor contains the Contact Form block the Fields metabox is not displayed as a table but as a serie of divs. |
The Message field is not redisplayed in the event of a form validation error. |
The Divi contact form, and many other contact forms, support multiple fields such as Telephone number.
I don't need a complex solution but it would be nice to include telephone as an additional field for the oik contact form block / shortcode.
Requirements
Proposed solution
oik/contact-form
block accordinglyThe text was updated successfully, but these errors were encountered: