MaxLazar / mx-title-control

Title field control ext. for ExpressionEngine
9 stars 7 forks source link

Channel Form entries always return empty string for url_title #7

Open joeczucha opened 9 years ago

joeczucha commented 9 years ago

As above (it works in the back end)

I've had a little look around:

In the entry_submission_end($entry_id, $meta, $data) function

$meta['url_title'] = ee()->api_channel_entries->_validate_url_title($url_title_name_out, $meta['title'], true); 

seems to be always be returning false.

The ee()->api_channel_entries->_validate_url_title function seems to be called twice, once with the original url_title and then with the updated url_title.

I guess this is to be expected (as it's being called by the original function, and again by the hooked version).

However the second time the value of $this->channel_id (in Api_channel_entries.php) is null, for some reason. This means that _unique_url_title function (in Api.php) fails, as the first line is:

if ($type_id == '') {
    return FALSE;
}

...so the URL is always returned as false.

Thanks!

joeczucha commented 9 years ago

The fix, it would seem, was simple and just involved passing the channel ID to the newly instantiated api_channel_entries object:

ee()->api_channel_entries->channel_id = $channel_id;