in javascript i can call prompt like this
var retVal = prompt("Enter the new first name : ");
how can i call same prompt in rjs file
i used, page.prompt("Enter the new first name : ")
and its not working
page << "prompt('Enter the new first name:');"
Related
I am using Laravel 5. In my Controller I am getting value from View like this method:
$params = array('' => Input::get("selected_category_id"));
then it showing in my log like this:
/api/zones/?=3
I try to modify which remove the single quote and equal symbol, like this:
$params = array(Input::get("selected_category_id"));
then it showing in my log like this:
/api/zones/?0=3
Can I set my url to be like this format:
/api/zones/3
thanks for any help!
As far as I understand your questions, you need to create a new route for it:
Route::post('/api/zones/{id}','YourController#processInput');
In the above route, replace YourController with the controller you are using to process the input and replace processInput with the method that actually processes it.
So, your controller would now have access to the category:
public function processInput(Request $request, $id)
{
$categoryID = $id;
}
I think the issue is with the UrlMapping file or some configuration file that I don't know about but I didn't see it addressed in this site so I'm posting for help.
I have a UrlMappings.groovy with:
"/lookupMap/$fromVal/$toVal/xml/$id**" (controller:"lookup, action:"returnMapXml", formats=['xml'], method:"GET")
and the controller is:
def returnMapXml = {
if (params.id) {
print params.id + "\n";
try {
def result = getLookup.result(params.fromVal, params.toVal, params.id)
render ...yadda yadda
}
}
}
This is a REST service. My problem happens when someone enters an ID value with either a pound sign (#) or question mark (?), the value is truncated at that character. For example the output of ID (per the print line in the code) for this: localhost:8080/productdefinition/lookupMap/Denver/Toronto/carton OR container OR box? OR bag would be carton OR container OR box It removes the ? and everything after it. This happens somewhere either before it gets to the UrlMappings file or when that directs the call to the controller. Either way, how can I stop this and where, which file do I fix this in? I don't have access to the server so I can't alter any URL encodings; this has to be a code update. Any help/direction would be appreciated.
I have problem:
When I fill in form and pressing add button page is reloaded, but no data is added to the database.
Code of NewsController, add action is below:
public function addAction() {
$form = new AddNewsForm();
$form->get('submit')->setValue('Add1');
$request = $this->getRequest();
if ($request->isPost()) {
$form->setData($request->getPost());
var_dump($form->isValid());
if ($form->isValid()) {
echo "form is valid";
$objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
$blogpost = new NewsItem();
$blogpost->exchangeArray($form->getData());
$blogpost->setCreated(time());
$blogpost->setUserId(0);
$objectManager->persist($blogpost);
$objectManager->flush();
// Redirect to list of blogposts
return $this->redirect()->toRoute('news');
}
}
return array('form' => $form);
}
Class AddNewsForm is included as use \News\Form\AddNewsForm as AddNewsForm; above.
I tried to debug my code and realized, that $form->isValid() return false all time. I tried to fill in all fields of form — it says that form is not valid. If not all fields are filled in it false too.
The problem is with validation, I think, so I will add here how I assing filter to the form. This is how I assing filter to my form:
$this->setInputFilter(new AddNewsInputFilter());
Class AddNewsInputFilter is included by this:
use \News\Form\AddNewsInputFilter as AddNewsInputFilter;
I don't think it is good to paste there ~100 lines of code, so I will just give a link to files in my github repo (full code of controllers/files available here):
AddNewsForm.php — file, where I create the form
AddNewsInputFilter.php — file, where I set fil
NewsController.php — file, controller, where I call created form
Repository link — root dir of my module
So the problem is that $form->isValid(); doesn't show is form valid or not properly and I don't know why. Note, that request is getting properly and first condition is passed (but second is not passed). It is the problem, thats why I am writing here.
How I can solve it?
Thanks is advance!
try var_dump($form->getMessages()) and var_dump($form->getInputFilter()->getMessages()) in controller(after calling $form->isValid()) or in view . see what error you getting and on witch element ?
NOTICE : getMessages() will be empty if $form->isValid() has not been called yet,
UPDATE : do this in controller :
var_dump($form->isValid());
var_dump($form->getMessages())
var_dump($form->getInputFilter()->getMessages())
I'm trying to use coffescript as views in Rails 3.2.11
I have create.js.coffee with the following lines:
is_valid = <%=#model.valid?%>
if is_valid
res = confirm("Are you sure you want to continue?")
if(res)
<%=#model.activate%>
window.location.href = "/blabla/models"
else
return
else
$('.form .field_with_errors').removeClass('field_with_errors')
jw_funcs.respond_with_error(<%=#response_invalid%>)
The problem is that the line of code <%=#model.activate%>
is executed every time. I think it depends on the fact that the erb engine runs independently from the coffee engine; If so, how can I do this ?
You really weren't expecting this coffee code to call your model method from the client's browser, were you?
Wrap #model.activate into its own controller action, which will be called by clients if the confirmation is given. Something like this:
res = confirm("Are you sure you want to continue?")
if(res)
$.ajax('/models/1234/activate', ...)
else
return
I am using the following code
s2ui:submitButton elementId='reset' form='resetPasswordForm'
messageCode='spring.security.ui.resetPassword.submit(msg)'/>
which gives me Msg+ a button with no value.
I wan that the button should have the msg in its value.
I tried even giving the explicit value field but it does not regard it.
How do I edit the button's value then.
+
How to align the s2ui form.
the problem was in the taglib
def submitButton = { attrs ->
String form =getRequiredAttribute(attrs, 'form', 'submitButton')
String elementId = getRequiredAttribute(attrs, 'elementId', 'submitButton') >
String text = resolveText(attrs)
def writer = getOut()
// writer << """
// writer << ">${text}\n"
writer << "\n"
String javascript = """\$("#${elementId}").button();
\$('#${elementId}').bind('click', function() {
document.forms.${form}.submit();});"""
writeDocumentReady writer, javascript
}
So this used to put the value as null and show the test as a link with a blank button
I got the problem was actually in the tag lib..
But as I could not commit my local changes of plugin to server it did not help. So may be we should edit the plugin at server too where we host our application or create own own taglib instead of using the plugin's.
So currently I am using my own submit button.