Jeradin / acf-website-field

Advanced Custom Fields add-on for Website URLs, allows for website URL, title and a checkbox to open externally or internally
59 stars 14 forks source link

Error message fired when field required #16

Closed aguidis closed 11 years ago

aguidis commented 11 years ago

First of all thanks for this plugin. I noticed a bug when I set my field required. Indeed even if I put a value to my url field, an error message is fired.

Jeradin commented 11 years ago

Thank you for the report, not sure how I missed ever testing the field as required!

This issue should be resolved.

aguidis commented 11 years ago

Thank you for your responsiveness. When I saw this error message at the beginning, I thought it was due to the url I set. But it was a correct format. Is it possible to not register the field if it's a wrong url instead of displaying a message on the front ?

Jeradin commented 11 years ago

Can you link a URL with the error message? I thought I disabled the front end error message.

Jeradin commented 11 years ago

Ah, tested and I see what you are referring to. The Invalid URL on the front end.

I am not sure that is a better solution, if someone puts in a bad url and nothing displays on the front end, wouldn't that be confusing? Trying to think of another option.

I don't want to add ajax to the admin to validate the url, so the front end was the only place I could think of.

aguidis commented 11 years ago

Is there a way to use your function for cleaning the url before register it in database ? I mean before the admin save the post ? I tried when I looked at your code but I failed ^^'

Jeradin commented 11 years ago

Can you post a URL that is causing an issue and I can run some validation tests.

ACF has a function to change a field value before it gets saved to the database...

    function update_value($value, $post_id, $field)
    {
        // Note: This function can be removed if not used
        return $value;
    }

But would like to run some tests before I mess with that.

aguidis commented 11 years ago

It was just an idea to optimize your plugin. I think it's better for the user experience to display an error message in the back office when the admin try to save his post with a wrong url.

Jeradin commented 11 years ago

I think its a good idea, sometimes I get nervous adding ajax/jquery to the admin though.

Can you add a URL that was giving you an issue and I will run some tests to see how to add the feature.

Thanks Aguidis.

aguidis commented 11 years ago

I simply tried the value 'test'. So in back office my post was updated and in my page I could read "bad url". At this moment, I was wondering if I could change the code in order to call a function when my post is about to be updated. In order to check the field's value. But I'm not totaly comfortable with with the hook so I failed like I said ^^