We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Channel Form hooks - how to verify an input before submit?

How Do I?

pelluche's avatar
pelluche
10 posts
5 years ago
pelluche's avatar pelluche

I have a channel form where I need to verify they know the league password before they can submit to be added to the “users” channel.

What’s the best way to hook into this? I’m gathering I’ll need to tie into the channel_form_submit_entry_start($channel_form_obj) but I’ve never used hooks so wondering if someone could give me a quick example. The docs aren’t very in depth for hooks.

Here’s my template flow:

{exp:channel:entries channel="leagues" require_entry="yes"}
    
    {exp:channel:form 
    channel="users" 
    include_assets="no"
    error_handling="inline"
    return="leagues/join-league-success/URL_TITLE"
   }
        // display league settings from entry they want to join which has a league pass they need to know
        <input type="password" name="verifyPassword" id="verifyPassword" placeholder="Enter League Password..." required>
       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

I think there are a number of ways you could go at it- and I wouldn’t nest the form inside an entry tag.

I’d actually consider making the password a custom field and then it’s just regular validation. Of course, that would be the case in the CP as well, but if that’s not problematic, that’s what I’d lean toward doing. And you can look at any of the fieldtypes in system/ee/EllisLab/Addons/ for good examples. That way validation of your password would work just like validation of any of the other fields.

But a hook is also a good way to go at it, especially if you did NOT want it to act like regular field validation. Take a look in channel_form/Channel_form_lib.php- find the hook. You can do just about anything you want it the password doesn’t validate. From stopping processing and returning a system message to throwing an error.

I think the option you want to go with will just depend on how you want the validation to work.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.