Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new select_prompt method to generate a blank option. #1124

Merged
merged 1 commit into from
Apr 30, 2020

Conversation

jwoertink
Copy link
Member

Purpose

Fixes #1027

Description

This adds a new select_prompt method to just generate a blank option so it's clear that this is just your prompt.

select_tag(operation.fighters) do
  select_prompt("Choose your character")
  options_for_select(operation.fighters, [{"SubZero", 1}])
end

Checklist

  • - An issue already exists detailing the issue/or feature request that this PR fixes
  • - All specs are formatted with crystal tool format spec src
  • - Inline documentation has been added and/or updated
  • - Lucky builds on docker with ./script/setup
  • - All builds and specs pass on docker with ./script/test

Copy link
Member

@paulcsmith paulcsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Just one thought on documentation. There are times when you don’t want to show the prompt. For example if the field is required and you’re on the edit page. In that case you can do operation.record to see if you’re working with an existing record. So you could do select_prompt(“whatever”) unless operation.record

I think it’d be cool to document that here or in the guides as an example since it is probably gonna be a common use case and people may not know how to do it.

Code looks good though!

@jwoertink jwoertink merged commit 7707f2b into master Apr 30, 2020
@jwoertink jwoertink deleted the features/1027 branch April 30, 2020 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new select_prompt method
2 participants