What is concept creating url / path for sonata page - I want create not hardcoded path in template. In doc https://sonata-project.org/bundles/page/master/doc/reference/twig_helpers.html have
8.1. URL
Render a page url
{{ path(page) }} => /absolute/path/to/url
{{ path(page, {}, true) }} => ../relative/path/to/url
{{ url(page) }} => https://sonata-project.org/absolute/url/to/url
{{ url(page, {}, true) }} => //sonata-project.org/network/path/to/url
what is page ?
i try page id , slug get error.
I have try it.
Variable page was not defined - so i think its just an example in sonata doc.
If you type in shell (symfony-root-folder)
php bin/console debug:router
You will get a list of all defined routes in your app.
You can use any name from this list as parameter. Eg: {{ url('sonata_admin_dashboard')}}
... and will get the Path from this list as path or url: Eg. http://localhost:8000/admin/dashboard
More Info:
https://symfony.com/doc/current/routing/debug.html
https://symfony.com/doc/current/routing.html
Related
I use mapbox tools for my autofill place address autocomplete on my project Symfony
I want to know how can i extract full complete address in autofill, i have 2 inputs one for search and one hidden for get full/complete address
<mapbox-address-autofill>
{{ form_widget( form.address, {
'attr': {
'class': 'form-control form-control-solid font-weight-bold',
'placeholder': 'Adresse de départ',
'required': 'required',
'autocomplete': 'address-line1'
}
} ) }}
{{ form_widget( form.address_value, {
'attr': {
'autocomplete': 'full-address'
}
}) }}
</mapbox-address-autofill>
I have this but with tag 'full-addresse' 'complete' 'place_name'
No one workn if you have any solution for get full address to persist this in php Symfony project
"full_address" is a property of the feature object that is returned from a retrieve event, but does not automatically map to any HTML form field autocomplete value. The only object properties that get mapped to HTML elements are the ones corresponding to WHATWG standards, i.e.:
'street-address'
'address-line1'
'address-line2'
'address-line3'
'address-level1'
'address-level2'
'address-level3'
'address-level4'
'country'
'country-name'
'postal-code'
I'm not familiar with PHP, but a way to do this in Javascript would be something like:
const autofill = document.querySelector('mapbox-address-autofill');
const targetInput = document.getElementById('myTargetInput');
autofill.addEventListener('retrieve', (event) => {
const featureCollection = event.detail;
const feature = featureCollection[0];
const fullAddress = feature.properties.full_address;
targetInput.value = fullAddress;
});
I'm trying to get a form.widget value with axios so i can pass it in a url. i tried :
const url = Routing.generate('route_name', {type: {{ formC.type.vars.value }});
but i get empty value.
Can anybody help?
I am using ionic page module like this...
#IonicPage({
name: 'forgotten-password',
segment: 'forgotten-password/:email/:code',
defaultHistory: [ 'home' ]
})
The problem is without providing params, the url looks like this:
http://localhost:8100/#/forgotten-password/:email/:code
How can I omit the :email and :code from the route when they are not provided?
I'm using Apostrophe CMS 2 and having difficulty displaying the url value.
index.js
{
type: 'url',
name: 'cta-video',
label: 'Call to Action Video'
},
widget.html
{{ data.widget.cta-video }}
I want to save data to the database by clicking on a button in a view file.
I would like to achieve this by calling a method in my controller via POST.
It works but I have to pass some variables/parameters ( without having inputfields ) to the controller and that doesn't work.
this is my controller:
class CouplesController extends BaseController {
public function postCreate($var1)
{
Couple::create(array(
'name'=>'test',
'id1'=>$var1
));
return Redirect::to('couples')
->with('message','Your couple was created successfully!');
}
}
and this is my view:
{{ Form::open(array('action' => 'CouplesController#postCreate', $var1->'hello')) }}
<p>{{ Form::submit('Create') }}</p>
{{ Form::close() }}
probably I'm doing this completely wrong. I just don't know how to do this.
btw it doesn't have to be the POST method.
You are really close, within your view:
{{ Form::open(array('action' => 'CouplesController#postCreate', 'hello')) }}
<p>{{ Form::submit('Create') }}</p>
{{ Form::close() }}
This will generate a URL similar to:
<form method="POST" action="http://localhost/couples/create/hello" accept-charset="UTF-8">
Then the rest of your code should work without an issue, and $var1 should be set to the value of hello.
I just saw that the error with the missing parameter appears while having this route:
Route::post('couples/done', 'CouplesController#postCreate');
when I take this route out it gives me this error:
Unknown action [CouplesController#postCreate].
like it doesn't have access to the controller in the view itself.
:(