2

Say, I want to validate an email address or a special URL e.g. YouTube URL, would I be able to use a custom plugin with the guestEntries.beforeSave hook to do this?

The basic hook call:

craft()->on( 'guestEntries.beforeSave', function(Event $event) {
    // Call custom validation here
});

Would I be able to setup a model with the method defineAttributes and run that?

1

The only model passed into the guestEntries.beforeSave event and returns from it is Craft's EntryModel, so even if you create your own MyEntryModel inside the event with it's own attributes and validation rules, there's not a clean way to return that model back to the controller to return to the template to display.

The easiest thing to do would be to fork the plugin and change GuestEntriesController so that's its using a custom MyEntryModel that extends Craft's EntryModel and adds it's additional attributes/validation rules as required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.