Yii2 MaskedInput with alias 'url' limits input to 60 characters - url

I am using the following code in Yii2:
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'link')->widget(MaskedInput::classname(), [
'clientOptions' => [
'alias' => 'url',
],
]) ?>
<?php ActiveForm::end(); ?>
It seems, that the input field is limited to 60 characters. How to remove this limitations?
See the URL example on: http://demos.krajee.com/masked-input

The limitation is in jquery.inputmask. See https://github.com/RobinHerbots/jquery.inputmask/issues/863. This limitation will disappear if the issue is solved and the new jquery.inputmask.js is included in Yii2 bower package.

Related

How to call ResolveCustomer and GetEntitlements from aws-marketplace in PHP?

I am using PHP Laravel, I can find PHP SDK, But I can't find any examples.
I need to call ResolveCustomer (produces a token for the product and user) and GetEntitlements (gives a list of rights for the product and the user).
Has anyone used this service?
I write this code works.
<?php
require 'aws/aws-autoloader.php';
use Aws\AwsClient;
use Aws\Credentials\Credentials;
use Aws\MarketplaceMetering;
$config = [
'credentials' => new Credentials('key', 'secret'),
'region' => 'us-east-1',
'version' => 'latest'
];
$client = new MarketplaceMetering\MarketplaceMeteringClient($config);
$x_amzn_marketplace_token = 'token';
$result = $client->resolveCustomer(['RegistrationToken' => $x_amzn_marketplace_token]);
echo "<pre>";
print_r($result);

How to create custom urls with dashes in Yii2?

I am working with advanced project application and trying to add URL rules in Yii2 to handle custom URLs with dashes.
What I want to do is to change the URL from
http://www.example.com/post/details?url=example-post-title
To
http://www.example.com/example-post-title
I have below configuration which works fine when the URL parameter does not have dash (exampleposttitle).
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
// ...
'<url:\w+>' => 'post/details',
],
],
You need to fix your regexp, since \w+ does not allow dashes:
'<url:[\w-]+>' => 'post/details',

Pjax in Yii 2 with POST request

How can I use Pjax in Yii 2 with POST request?
I tried to do it like that but page restarts anyway:
<?php Pjax::begin(['id' => 'some-id', 'clientOptions' => ['method' => 'POST']]);?>
...
some content
...
<?=Html::a('', ['cart/cart'],
['class'=>'close1',
'data' => [
'method' => 'post',
'params' => [
'idCartToDelete' => $product->idCart,
],
]
]
)
?>
...
some content
...
<?php Pjax::end(); ?>
You're close to solving your issue. To your Html::a parameters add:
'data-pjax' => 0,
And you will have a link that does not redirect to another page.

How to config Zend Frameword 2 output cache

I'm using output cache in zend framework 2:
$outputCache = Zend\Cache\PatternFactory::factory(
'output',
array(
'storage' => 'apc'
)
);
$outputCache->start('mySimpleViewScript');
include '/path/to/view/script.phtml';
$outputCache->end();
Please help me config time cache(ttl) and cache_dir.
Thanks.
If you pass storage by string ('apc' in your example), specific storage implementation is pulled from Zend\Cache\Storage\AdapterPluginManager as invokable with default options (ttl is 0 by default).
If you need custom options, just create your cache storage directly, it is covered by cache storage adapter documentation:
$cache = Zend\Cache\StorageFactory::factory([
'adapter' => [
'name' => 'apc',
'options' => [ 'ttl' => 3600 ],
],
]);
$outputCache = Zend\Cache\PatternFactory::factory('output', [
'storage' => $cache,
]);
cache_dir is not valid option for Apc adapter.

Symfony 1.4 Path to modules

Following structure:
apps/backend/
apps/frontend/
modules/
account/template/_menu.php
account/template/test.php
settings/template/indexSuccess.php
I do include _menu in test.php with the following code:
<?php slot('menu'); ?>
<?php include(dirname(__FILE__).'/_menu.php') ; ?>
<?php end_slot() ?>
How can I include the file _menu.php in indexSuccess.php?
Thanks!
Gunnar
You want to use include_partial from the indexSuccess.php template:
// indexSuccess.php
// Use the array container to pass values available in indexSuccess to your partial
<?php include_partial('menu', array(
'foo' => $foo,
'bar' => $bar
)) ?>
You can read more about it in Symfony API Docs.

Resources