I'd like to be able to create feed nodes in advance, before I have the feed file to upload.

However, this is not possible because the validation in feedapi_node_validate doesn't allow this.

CommentFileSizeAuthor
#11 feedapi_node_validate.patch2.63 KBb-prod
#5 feedapi.patch3.52 KBb-prod

Comments

aron novak’s picture

Correct me, if i'm wrong, but in general, feedapi happily creates feed nodes w/ invalid URL as long as you supply the feed node title.
It should be true for file:// pathes as well.
edit: maybe w/ file://, it's a little bit different compared to the file upload form, but maybe it's still an option

alex_b’s picture

Conceptually, there is no reason why it shouldn't be possible to create feed nodes without specifying the URL. Killes: where exactly does feedapi_node_validate() complain?

Alex

killes@www.drop.org’s picture

It complains if I didn't enter a feed and did not upload a file:



 // Validate and transform settings for submission.
  if (empty($form_state['values']['feedapi']['feedapi_url']) && !$has_upload) {
    form_set_error('source', t('The Feed URL or uploading a file is required.'));
  }
  else 

alex_b’s picture

#3: Sorry, should have read this out of the code myself. I was too sure that we were allowing this.

IMO, we could remove this check. We will have to make sure that refreshing does fail graciously though.

Aron - thoughts?

b-prod’s picture

StatusFileSize
new3.52 KB

This patch add a settings option in node type edit form. So it is possible to choose if the feed URL or uploaded file is mandatory (default behavior) for saving a feed node.

In case of these fields are not required, it take care of the node title (it cannot be retrieved from unexisting file) and displays an error if title is empty.

For URL field, the standard form API handling is used for an empty field. For file upload field, it is not possible because of a well-known bug in Drupal file field handler.

alex_b’s picture

Status: Active » Needs work

I would suggest to try to use FormAPI.

- As the behavior up to now has been that a URL is required, let's add a '#required' = TRUE flag to the URL field.
- Remove the manual validation step from feedapi_node_validate()
- If a non-required behavior is desired, it can be removed via form_alter() in a custom module.

This would a) bring this behavior in line with what Drupal API users would expect b) does not crowd our UI with a setting for corner cases.

I would love to hear Aron's opinion on this, because I'm thinking there is a reason for why the the FormAPI #required property isn't being used.

aron novak’s picture

At the simplified feed create form, the URL is ensured via #required, so i'm pretty sure there is no serious reason against using #required => TRUE. The #6 just makes sense not to alter the behaviour, but allowing to override it.

gerhard killesreiter’s picture

the problem with that approach is that I'll then need to override the entire validation function in my custom module. I wanted to avoid that.

Also, you already add the upload form though hook_form_alter so a potential custom module needs to take weights into account. This is getting messy...

b-prod’s picture

For information: the bug is known and described here.

Note: the #required property is not supported (setting it to true will always cause a validation error). Instead, you may want to use your own validation function to do checks on the $_FILES array with #required set to false. You will also have to add your own required asterisk if you would like one.

alex_b’s picture

Status: Needs work » Needs review

#9: good find. Thank you for digging this up.

Seems like the variable is the way to go. NR again. Will review as soon as possible.

b-prod’s picture

StatusFileSize
new2.63 KB

Here is an updated patch for the dev version which has changed since the first patch.

adub’s picture

I'm working on a services client parser module which will form_alter this field into a select box with non-url values - not sure if this could affect that kind of functionality.