Remove "none" option from the fallback select list if the field is required. Should just have the options. If optional, then none should be the first/default option. This is the same behavior that the standard node reference field exhibits.

Great module btw! Just recently discovered it and its changed a few ways that I work with Drupal.

CommentFileSizeAuthor
#10 node-reference-url-widget-742074-9.patch783 bytesmanur0

Comments

quicksketch’s picture

So you're suggesting that "none" be the first option? I don't actually like "none" much at all and I wouldn't recommending using it, since it actually makes the field impossible to enter anything at all. Up until the last round of changes, it also made it so that you couldn't even later edit the node and add a reference. Right now it's difficult to hide certain fields based on if a field is required or not, since the "Required" checkbox is on the same page, we'd have to do an AJAX request to properly hide/show the radiobutton, which I'm not very keen on, especially since I don't think it really makes much sense to do so.

keesee’s picture

I agree that I don't like none as an option... but it is required on select lists. the thing that irritates me is that when the field is required, you have none on the list. You are giving the user an option that that isn't allowed, given that if they pick it the form will not validate. On the other hand, if it is not required, you must have it (at the top) so that the user isn't force into picking an option and it will not make a selection for them if they ignore -- otherwise its essentially required.

The core node reference module does a great job of handling this user case in that if the field is required and its a select list, it removes the 'none', otherwise its there for other node reference select fields so they aren't forced to pick an option.

--
Thanks for the quick reply.

quicksketch’s picture

I'm terribly confused (I thought you were talking about the "leave empty" widget, not the "none" option in select lists), could you post a screenshot? Node Reference URL Widget uses the normal Node Reference widgets for everything, so it should behave exactly the same when using the fallback behaviors.

quicksketch’s picture

Status: Active » Fixed

the thing that irritates me is that when the field is required, you have none on the list.

As far as I know the "None" option will only show up in the select list if you haven't set a default value. If you set a default value for the list, this "None" option will disappear. Again, this is a Node Reference issue more than a Node Reference URL issue, since that functionality is provided by Node Reference itself.

keesee’s picture

Thanks for the follow up. I had planned to play around with it this weekend and take screen shots. Given what you told me... I need to find a way to select a default so that the none goes away. From a user interaction perspective, a required field should not have none as an option. I'll play around with it. It appears that I don't have a default value field for this module when adding it to a cck content type.

More later, but my question is can we override using form alter and remove the none option - would add that as a field setting? Or can we be allowed to select a default value?

Thoughts?

quicksketch’s picture

From a user interaction perspective, a required field should not have none as an option.

This isn't necessarily true, while "none" is a poor title ("select..." is more appropriate), it can be useful if you don't want to introduce selection bias just because the first option is already selected for you, resulting in users not changing the default. A good example of this is something like a drop-down of states. Even though it may be required, you probably don't want "Arkansas" to be the default.

Or can we be allowed to select a default value?

I think maybe Node Reference URL Widget might turn off the default value select (not sure about this), because it's assumed that a default is going to already be provided through the URL.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

criznach’s picture

Status: Closed (fixed) » Active

I've been battling this too. Turns out the - None - value is always added by Node Reference URL in an after_build handler. Quicksketch, I see your point on the selection bias. I may just hide mine with JQuery because I ensure that there is always one valid choice, but an option on the field settings would be nice.

quicksketch’s picture

Status: Active » Postponed

I don't find this a problem enough that I'll spend any time on it. If you'd like to recommend a patch I'll review it.

manur0’s picture

Assigned: Unassigned » manur0
StatusFileSize
new783 bytes

Here is the patch.

monotaga’s picture

Status: Postponed » Active

IMHO, it seems that there either needs to be the ability to set a default value as part of the "Fallback behavior" process and/or to at least remove "none" when the field is required (like in manur0's patch in #10, which seems to work for me)

Any thoughts?

quicksketch’s picture

Status: Active » Postponed

manur0's patch in #10 doesn't address my concern from #6. Required and an empty option are not mutually exclusive. I think restoring the ability to set a default value as part of the fallback is a better way to go. Again, I'm not spending time on this though, so I'm moving it back to postponed. Please set to needs review if a patch can be provided.

quicksketch’s picture

Title: Fallback select list » Remove the "None" option from the fallback select list