Laravel "Method does not exist" but only online. - jquery-mobile
I have a view (mobilepage2) with a button "next". The frontend is jquery mobile the backend is laravel. I only have one controller.
When i click the "next" button i get the error:
{"error":{"type":"BadMethodCallException","message":"Method [testfunction] does not exist.","file":"\/home\/safety\/domains\/safetyanalyse.nl\/public_html\/dev-sac\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Controller.php","line":229}}
The strange thing is that my app works fine and shows no error in my localhost. It does show an error on my server online.
This is my MobileController code
public function testfunction(){
View::share('waarschijnlijkheid','test');
View::share('effect','test');
View::share('blootstellingsfreq','test');
View::share('risico', 'test');
return View::make('mobilepages.mobilepage5');
}
This is a part of my routes.php
Route::post('gotomobilepage5', 'MobileController#testfunction');
This is my mobilepage4.blade.php View
#extends('mobilemaster')
#section('content')
{{Form::macro('jradio', function()
{
return '<input type="radio"';
});
}}
{{Form::macro('jradio2', function($name,$id,$value,$checked)
{
return '<input type="radio" name='.$name.' id='.$id.' value='.$value.' checked='.$checked.' >';
});
}}
{{ Form::open(array('url' => 'gotomobilepage3', 'method' => 'post')) }}
<div data-role="collapsible">
<h3>Blootstellingsfrequentie(B)</h3>
<fieldset data-role="controlgroup">
<label for="radio-choice-v-2a">0 Nooit</label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2a' ,'0',"checked") }}
<label for="radio-choice-v-2b">1/2 Zeer zelden {{'(<1x/jaar)'}}</label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2b' ,'0.5',"") }}
<label for="radio-choice-v-2c">1 Zelden{{'(jaarlijks)'}} </label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2c' ,'1',"") }}
<label for="radio-choice-v-2d">2 Soms{{'(maandelijks)'}}</label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2d' ,'2',"") }}
<label for="radio-choice-v-2e">3 Af en toen{{'(wekelijks)'}}</label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2e' ,'3',"") }}
<label for="radio-choice-v-2f">6 Regelmatig {{'(dagelijks)'}}</label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2f' ,'6',"") }}
<label for="radio-choice-v-2g">10 Voortdurend</label>
{{ Form::jradio2('radio_blootstellingsfreq','radio-choice-v-2g' ,'10',"") }}
</fieldset>
</div>
<div data-role="collapsible">
<h3>Effect(E)</h3>
<fieldset data-role="controlgroup">
<label for="radio-choice-v-2a">0 Geen</label>
{{ Form::jradio2('radio_effect','radio-choice-v-2a' ,'0',"") }}
<label for="radio-choice-v-2b">1 Gering</label>
{{ Form::jradio2('radio_effect','radio-choice-v-2b' ,'1',"") }}
<label for="radio-choice-v-2c">3 Belangrijk</label>
{{ Form::jradio2('radio_effect','radio-choice-v-2c' ,'3',"") }}
<label for="radio-choice-v-2d">7 Ernstig</label>
{{ Form::jradio2('radio_effect','radio-choice-v-2d' ,'7',"") }}
<label for="radio-choice-v-2e">15 Zeer Ernstig</label>
{{ Form::jradio2('radio_effect','radio-choice-v-2e' ,'15',"") }}
<label for="radio-choice-v-2f">40 Ramp</label>
{{ Form::jradio2('radio_effect','radio-choice-v-2f' ,'40',"") }}
</fieldset>
</div>
<div data-role="collapsible">
<h3>Waarschijnlijkheid(W)</h3>
<fieldset data-role="controlgroup">
<label for="radio-choice-v-2a">1/10 Bijna niet denkbaar</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2a' ,'0.1',"") }}
<label for="radio-choice-v-2b">1/4 Praktisch onmogelijk</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2b' ,'0.25',"") }}
<label for="radio-choice-v-2c">1/2 Denkbaar, maar onwaarschijnlijke</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2c' ,'0.5',"") }}
<label for="radio-choice-v-2d">1 Onwaarschijnlijk, mogelijk in grensgeval</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2d' ,'1',"") }}
<label for="radio-choice-v-2e">3 Ongewoon</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2e' ,'3',"") }}
<label for="radio-choice-v-2f">6 Zeer wel mogelijk</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2f' ,'6',"") }}
<label for="radio-choice-v-2g">10 Te verwachten</label>
{{ Form::jradio2('radio_waarschijnlijkheid','radio-choice-v-2g' ,'10',"") }}
</fieldset>
</div>
{{Form:: submit("VERDER")}}
{{ Form::close() }}
As you can see my testfunction exists. What could be the problem? :(
Try composer dump-autoload and/or php artisan optimize on the webserver to make sure that it is seeing all autoloaded/compiled classes.
Related
How to compare emails in javascript?
I am trying to make an edit profile page in which user can update its current email or pwd by inputting current email and password and then give new ones. I am also sending whole data of user(including username and password) when he sign in through viewdata. #{ var user = (User)ViewData["User"]; } <div class="account-info mt-3"> <fieldset class="border border-dark p-3"> <legend class="float-none w-auto">Account Info</legend> <div class="mb-3 simpleinfo"> <label for="email" class="form-label">Enter Your Current Email</label> <input type="email" class="form-control" name="Username" id="prevemail"/> </div> <div class="mb-3 simpleinfo"> <label for="prevpwd" class="form-label">Enter Your Current Password</label> <input type="password" class="form-control" name="Pwd" id="prevpwd"/> <button type="button" class="btn btn-success mt-4 checkcred">Update Credentials</button> </div> <div class="mb-3 simpleinfo"> <label for="email" class="form-label">Enter new Email</label> <input asp-for="Username" disabled type="email" class="form-control" id="newemail"> </div> <div class="mb-3 simpleinfo"> <label for="newpwd" class="form-label">Enter New Password</label> <input type="password" disabled class="form-control" asp-for="Password" id="newpwd"> </div> </fieldset> </div> Now i want to compare the email that user enters and the email that is present in the user object. here's my code for this: <script> $('.checkcred').click(function() { var prevemail = $('#prevemail').val(); var prevpassword=$('#prevpwd').val(); if(prevemail==#user.Username&&prevpassword==#user.Password) { alert("Validated"); } else { alert("not validated"); } }); </script> But it is giving me syntax error on Console: Invalid or unexpected token. Please lemme know what i am doing wrong.
Connecting dynamically generated input field to mat-autocomplete
I am allowing users to create input fields dynamically. For each of these input fields i want to connect it to a different mat-autocomplete so that they work independently of each other. I have hit a brick wall here because I cannot create element reference(#auto here) dynamically that connects the auto-complete to input. How do I achieve this? <div class="row" *ngFor="let field of getControls('requestFields'); let i = index" formArrayName="requestFields" > <ng-container [formGroupName]="i"> <div class="col-md-4"> <mat-form-field class="example-full-width"> <input type="text" placeholder="Name" matInput formControlName="reqName" matAutocomplete="auto" /> <mat-autocomplete #auto="matAutocomplete"> <mat-option *ngFor="let option of (filteredColumns | async)" [value]="option" > {{ option }} </mat-option> </mat-autocomplete> </mat-form-field> </div> <div class="col-md-2"> <div class="togglebutton"> <label> <span>Optional</span> <input type="checkbox" formControlName="reqOption" /> <span class="toggle"></span> </label> </div> </div> <div class="col-md-4"> <mat-form-field> <input matInput formControlName="reqValidations" placeholder="Validation" type="text" /> </mat-form-field> </div> </ng-container> </div>
A nice thing about mat-autocomplete is that it is completely decoupled from the mat-form-field therefore you can put it at any place outside the scope of dynamically-generated rows. So taking your example - the solution could look like this: <div class="row" *ngFor="let field of getControls('requestFields'); let i = index" formArrayName="requestFields" > <ng-container [formGroupName]="i"> <div class="col-md-4"> <mat-form-field class="example-full-width"> <input type="text" placeholder="Name" matInput formControlName="reqName" matAutocomplete="auto" /> </mat-form-field> </div> <!-- other dynamic content --> </ng-container> </div> <mat-autocomplete #auto="matAutocomplete"> <mat-option *ngFor="let option of filteredColumns | async" [value]="option"> {{ option }} </mat-option> </mat-autocomplete> Then you could have an event handler for keyup on the input that triggers update for filteredColumns <mat-form-field class="example-full-width"> <input type="text" placeholder="Name" matInput formControlName="reqName" matAutocomplete="auto" (keyup)="reqNameChanged(field.get('reqName')?.value)" /> </mat-form-field> And in your component you can set up an filteredColumns observable that gets triggered by a subject from the keyup event handler: import { Component, OnInit } from '#angular/core'; import { Observable, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, filter, switchMap } from 'rxjs/operators'; #Component({ selector: 'example', templateUrl: './example.html', styleUrls: ['./example.scss'] }) export class ExampleComponent implements OnInit { filteredColumns: Observable<string[]>; reqNameSubject: Subject<string> = new Subject<string>(); constructor(private lookup: ILookupService) {} ngOnInit() { this.filteredColumns = this.reqNameSubject.pipe( filter(v => !!v), debounceTime(300), distinctUntilChanged(), switchMap(value => /* call for the autocomplete data */ this.lookup.search(value) ) ); } reqNameChanged(value: string) { this.reqNameSubject.next(value); } } I hope that it helps.
laravel 5.3 textarea doesn't work has no action
I'm a web developer. I have a problem. /resources/views/add.blade.php <textarea class="form-control col-md-7 col-xs-12" rows="5" id="content" name="content" required="required"> {{ empty($data['content']) ? old('content') : $data['content'] }} </textarea> NewsController.php public function getUpdate($id) { $news = News::find($id); if(empty($news->id)) { return view('news.update')->withErrors([trans('error.edit', ['value' => 'NewsUpdate'])]); } return view('news.update', 'data' => $news]); } like that coded, textarea "content" has no value. Of course $data['content'] have value. If coded like that text 'content' has value. <input type="text" class="form-control col-md-7 col-xs-12" id="content" name="content" value="{{ empty($data['content']) ? old('content') : $data['content'] }} required="required"> Anyone help me.
sorry I have a mistake. I tried to $data['conntent']. My spelling is false. <textarea type="text" class="form-control col-md-7 col-xs-12" rows="5" id="content" name="content" value="{{ empty($data['content']) ? old('content') : $data['content'] }}" placeholder='#lang('menuview.News.Content')' required="required">{{ $data['content'] }} </textarea>
in your case: <textarea class="form-control col-md-7 col-xs-12" rows="5" id="content" name="content" required="required"> <?php empty($data['content']) ? old('content') : $data['content']; ?> </textarea>
ionic app ajax call works in browser with "ionic serve" but not on ios device with "ionic upload"
Breaking my head on this one for 3 days already. The app works in the browser but not on the ios device. If I alert the data from the ajax call it is returned null on the ios device. REGISTER.HTML <div ng-controller='MainCtrl'> <div class="list"> <span>test{{responseMessage}}</span> <label class="item item-input item-stacked-label"> <span class="input-label">Username</span> <input class="form-control" type="text" ng-model="username" placeholder="Username"> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Email</span> <input class="form-control" type="text" ng-model="email" placeholder="Email"> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Password</span> <input class="form-control" type="password" ng-model="password" placeholder="Password"> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Password retype</span> <input class="form-control" type="password" ng-model="retypepassword" placeholder="Retype password"> </label> <button class="button button-block button-positive" ng-click="register()">Register</button><br> </div> </div> APP.JS .controller('MainCtrl', function($scope, $ionicSideMenuDelegate, $http) { $scope.register = function () { var request = $http({ method: "post", url: "https://www.dummylink.com/app/php/register.php", data: { username: $scope.username, email: $scope.email, password: $scope.password, retypepassword: $scope.retypepassword }, headers: { 'Content-Type': 'application/x-www-form-urlencoded'} }); request.success(function (data) { $scope.responseMessage = data; }); request.error(function (data) { alert(data); }); } })
First a big thanks to tommybananas for trying to help me! Eventually the problem wasn't CORS related. The problem was that my ssl certificate wasn't installed correctly. I removed it and installed it again. Now everything is working!
Swapping content in Angular Material Dialog
I am trying to create a Login/Register dialog using Angular Material. The dialog should switch between a login page and a register page when you click the 'Switch' button. Here is the dialog html <md-dialog> <md-dialog-content> <div ng-if="lc.show_form == 'login'"> <form name="loginForm" ng-submit="loginForm.$valid && lc.login()" novalidate> <md-input-container> <label>Email</label> <input type="email" name="email" required ng-model="project.email"> <div ng-messages="loginForm.email.$error" ng-if="loginForm.email.$dirty"> <div ng-message="required">This is required.</div> </div> </md-input-container> <md-input-container> <label>Password</label> <input type="password" name="password" required ng-model="project.password"> <div ng-messages="loginForm.password.$error" ng-if="loginForm.password.$dirty"> <div ng-message="required">This is required.</div> </div> </md-input-container> <md-button ng-click="lc.login()" class="md-raised md-primary">Login</md-button> <md-button ng-click="lc.showRegister()">Switch</md-button> </form> </div> <div ng-if="lc.show_form == 'register'"> <form name="registerForm" ng-submit="registerForm.$valid && lc.register()" novalidate> <md-input-container> <label>Email</label> <input type="email" name="email" required ng-model="project.email"> <div ng-messages="loginForm.email.$error" ng-if="loginForm.email.$dirty"> <div ng-message="required">This is required.</div> </div> </md-input-container> <md-input-container> <label>Password</label> <input type="password" name="password" required ng-model="project.password"> <div ng-messages="loginForm.password.$error" ng-if="loginForm.password.$dirty"> <div ng-message="required">This is required.</div> </div> </md-input-container> <md-input-container> <label>Password Confirm</label> <input type="password_confirm" name="password_confirm" required ng-model="project.password_confirm"> <div ng-messages="loginForm.password_confirm.$error" ng-if="loginForm.password_confirm.$dirty"> <div ng-message="required">This is required.</div> </div> </md-input-container> <md-button ng-click="lc.register()" class="md-raised md-primary">Register</md-button> <md-button ng-click="lc.showLogin()">Switch</md-button> </form> </div> </md-dialog-content> </md-dialog> here is the controller code angular.module('dialogDemo', ['ngMaterial']) .controller('AppCtrl', function($mdDialog, $log) { $mdDialog.show({ controller: 'dialogCtrl', controllerAs: 'lc', templateUrl: 'loginDialog.tmpl.html' }); }) .controller('dialogCtrl', function($scope, $log) { var self = this; self.show_form = 'login'; self.showRegister = function() { self.show_form = 'register'; console.log('show register'); }; self.showLogin = function() { self.show_form = 'login'; console.log('show login'); }; }); Here is a plunker of what I am trying to accomplish. http://plnkr.co/edit/nLeJHZB9XiIiiR9fPNEe?p=preview Click the switch button. You will notice that the content changes, but if you click the switch button a second time the dialog only resizes, If you click it a third time it switches back. I am trying to figure out why it won't switch between the two views with only one click of the button.
Your plunker is working well for me. I press login and i get the login modal, then i press register and the modal turns into register modal. If i press login again i get login modal. pd: I am using chrome.