I'm working on a site in Symfony that displays graphs of a range of metrics.
Currently I'm trying to implement a simple datepicker to decide what graph to show.
Preferably in one of these forms:
a simple calendar icon that presents a calendar when clicked
three drop-downs for the day, month and year
The latter only as a plan-b really, the first would be great.
Now, I'm new to Symfony and I'm quite spoiled. Everything I wanted so far has always been but a plugin/helper/tag away. I sort of hoped that it was the same for a date-picker like this one, but so far I'm coming up empty. There are a few possibilities, but they all require a crap-load of dependencies and seem to have a low success-rate with people who have tried to implement them.
I have the feeling that I'm overlooking something that's right in front of me.
So in short: what is, according to you guys, the simplest way to implement such a date picker in Symfony? And if you have one, do you have a link with a clean and clear explanation?
Thanks a bunch,
Dieter
I use sfWidgetFormJQueryDate widgets based on jquery-ui from sfFormExtraPlugin.
class YourFormFilter extends BaseYourFormFilter
{
public function configure()
{
$date_widget = new sfWidgetFormJQueryDate(array(
'date_widget' => new sfWidgetFormDate(array('format' => '%day%/%month%/%year%')),
'culture' => 'ru'
));
}
}
Check this one, it is intended for Syfmony2
http://blog.azancadas.com/2011/07/symfony2-datepicker/
Related
Has anyone had any luck in figuring out how to use the react library https://react-day-picker.js.org/docs/input/
With Capybara/Selenium? Unfortunately it doesn't allow simply typing in the text such as MM/DD/YYYY like most date-pickers. This only allows mouse selection.
Or is specifically setting the value basically the only way to do so?
Without an example which shows the actual configuration of react-day-picker you're dealing with it's impossible to say exactly what you need to do, but the general rule is if you are testing the sites functionality then do what a user would need to do. In your case that may mean click on the forward/back month arrows until you get to the desired month, then click on the specific day element. Assuming the date you want to select is in the future (September 20, 2019) it would be something like
caption = find('.DayPicker-Caption')
until caption.has_text?('September 2019', wait: 0) do
current_month = caption.text
find('.DayPicker-NavButton--next').click
# wait for month to change
expect(caption).not_to have_text(current_month)
end
find('.DayPicker-Day', exact_text: '20').click
If you're not actually testing functionality (web scraping, etc) then you can use execute_script to call the react-day-picker JS API and set a specific date.
I'm hopping this awesome community can steer me on the right direction. I came from the flash/flex/js world, and I like how simple it is to define an item renderer in flex. Here is what I'm trying to accomplish:
I have an Angular component which consist of a form and a html table. I have the columns, headers, rows, etc. all populating correctly using ng-repeat. I want to be able to define column "renderers", so if someone passes me a column property like "renderAs: 'button'" or "renderAs: 'progress'" I should be able to render the entire column as a button, or progress bar, etc.
Here is what I've tried so far:
ng-bind-html="getColRenderer(column.renderAs, column.value)" which
returns HTML based on 'renderAs'. As you all probably know, this
will only work with basic HTML stuff, but I cannot append an
'ng-click', or an 'href' due to angular's security. So, I opted
for something else.
I semi-have a good solution embedding a "ng-switch" inside my
ng-repeat. I had an ng-if but with several types of potential
"renderers" I opted for the switch. This somehow seems like future
problems while trying to display too many columns or rows, just my
fears.
Decorators - I like decorators, but it seemed a bit too much for
something as a simple button that calls something on click or a
progress bar with 2 values. So, I halted going into this path, but
if this is the shinning path all walk, then by all means.
I hope someone out there has ran/done something like this and can steer me on the right course of action. If the ng-switch or ng-if is okay, then I'm good to go.
Once again, thank you in advanced.
I'm creating a very, very basic helpdesk system for a friend in Symfony. I have everything up and running now, but there are some usability issues that make the whole thing seem clunky.
The main problem is that after the user creates a new help ticket or edit an existing one, the next page they see is the edit page for that ticket. I would much prefer to show the user the ticket index. Does anyone know where and how I'd go about setting that up? I'm guessing there's a method I need to call in the Actions.class.php, but I just can't seem to figure out what it is.
(The editing/creating actions are more-or-less the ones Symfony auto-generated, with a little bit added to autofill a form, if that matters.)
I'm completely sure that this problem will take little work to fix, but I've really been struggling to Google this issue because of how common phrases like "next page" and such are. Any help will be very much appreciated!
Since I can't get code to newline properly in the comments, here's the last part of my update action:
public function executeUpdate(sfWebRequest $request)
{
...
$this->form = new NoteForm($note);
error_log("This line will be executed");
$this->processForm($request, $this->form);
error_log("This one won't.");
$this->setTemplate('index');
error_log("Neither will this one.");
$this->redirect('#homepage');
}
SOLUTION:
Just modify the redirect in the processForm definition in the actions.class.php for the item.
in your actions file, there must be an edit or maybe update action, which creates/updates your ticket. At the end of this action, simply do a $this->redirect('#ticket_index'); (ticket_index is the name of the ticket index route, which you can find in your routing.yml file).
The auto_complete_for dealio from script.aculo.us is great an all, but is there a way for me to selectively disable the fact that it always auto-selects the first item in the list?
The problem is that, if I want to type my own entry that is new, and novel, I don't want the first item in the list to be auto-selected. The reason is because when I TAB out of the field, it selects, and fills the text box with that first item.
I got around that, somewhat, by making the first item in the list the same as what I'm typing, but that's not perfect either, because the auto_complete list doesn't always update with every keystroke, depending on how fast I type. I've tried setting the list refresh rate to the lowest value (1 millisecond) but no go.
What I really want is an option in "auto_complete_for" that doesn't select that first item at all - the same way that Google Instant doesn't automatically select the first suggested search phrase - you have to arrow-down to select one.
Maybe I can do this via an HTML option that I'm missing?
Looking at the source, there doesn't appear to be an option for that, but I bet if you changed line 284 of controls.js to this.index = -1; it would do what you want.
Otherwise, it might be time to look for a different autocomplete widget.
If your requirements are too far away from the available plugin, then I guess there is no point in tinkering around. Its best to write your own JS code.
You might want to consider this: https://github.com/laktek/jQuery-Smart-Auto-Complete
or this : https://github.com/reinh/jquery-autocomplete
I'll add another alternative that works great with Rails 3:
http://github.com/crowdint/rails3-jquery-autocomplete
I recently implemented auto complete for more than a field for Rails 2.0.2.
The plugin I used is:- https://github.com/david-kerins/auto_complete . Not sure if it supports Rails 3.
I have also encountered issues on implementing the above scenario and have posted questions( Implementing auto complete for more than one field in Rails ; Implementing a OnClick kind of functionality and formatting wrt Rails Partial-Views ) on stackoverflow for the same, I have been lucky on getting things working for me based on my requirement.
Kindly refer to these questions, they might have relevance to your requirement.
I want to design a calendar in asp.net mvc and I want to take month information as a string in address bar. What should I do? And after that I have to show this month from index.aspx. How can I do this?
It's a little unclear what you're trying to do. If you're trying to present a calendar so that a user can input a date, I'd use jQueryUI's datepicker. The default style looks pretty nice, it's simple to use, and it works really well.
After re-reading your question, it seems you want your URL to be in some sort of date format. If this is the case, you need a custom route, like the one in this article. After you have created your custom route, printing the date is rather simple: pass the month part of the date from your controller down to your view and display it.